Skip to content

Commit

Permalink
Merge pull request #7947 from pjsde/refactor-routecollection-phpstan
Browse files Browse the repository at this point in the history
Refactor: Apply PHPStan rule "Short ternary operator is not allowed" to RouteCollection
  • Loading branch information
kenjis authored Sep 20, 2023
2 parents d3d6875 + d736bcf commit 2ad658d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -3031,11 +3031,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

0 comments on commit 2ad658d

Please sign in to comment.