Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Apply PHPStan rule "Short ternary operator is not allowed" to RouteCollection #7947

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2316,11 +2316,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Router/RouteCollection.php',
];
$ignoreErrors[] = [
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
'count' => 2,
'path' => __DIR__ . '/system/Router/RouteCollection.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Router\\\\RouteCollectionInterface\\:\\:add\\(\\) has parameter \\$to with no signature specified for Closure\\.$#',
'count' => 1,
Expand Down
5 changes: 3 additions & 2 deletions system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ public function __construct(FileLocator $locator, Modules $moduleConfig, Routing

// Normalize the path string in routeFiles array.
foreach ($this->routeFiles as $routeKey => $routesFile) {
$this->routeFiles[$routeKey] = realpath($routesFile) ?: $routesFile;
$realpath = realpath($routesFile);
$this->routeFiles[$routeKey] = ($realpath === false) ? $routesFile : $realpath;
}
}

Expand Down Expand Up @@ -1699,7 +1700,7 @@ public function resetRoutes()
*/
protected function loadRoutesOptions(?string $verb = null): array
{
$verb = $verb ?: $this->getHTTPVerb();
$verb ??= $this->getHTTPVerb();

$options = $this->routesOptions[$verb] ?? [];

Expand Down