Skip to content

Commit 2ad658d

Browse files
authored
Merge pull request #7947 from pjsde/refactor-routecollection-phpstan
Refactor: Apply PHPStan rule "Short ternary operator is not allowed" to RouteCollection
2 parents d3d6875 + d736bcf commit 2ad658d

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

phpstan-baseline.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,11 +3031,6 @@
30313031
'count' => 1,
30323032
'path' => __DIR__ . '/system/Router/RouteCollection.php',
30333033
];
3034-
$ignoreErrors[] = [
3035-
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
3036-
'count' => 2,
3037-
'path' => __DIR__ . '/system/Router/RouteCollection.php',
3038-
];
30393034
$ignoreErrors[] = [
30403035
'message' => '#^Method CodeIgniter\\\\Router\\\\RouteCollectionInterface\\:\\:add\\(\\) has parameter \\$to with no signature specified for Closure\\.$#',
30413036
'count' => 1,

system/Router/RouteCollection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ public function __construct(FileLocator $locator, Modules $moduleConfig, Routing
302302

303303
// Normalize the path string in routeFiles array.
304304
foreach ($this->routeFiles as $routeKey => $routesFile) {
305-
$this->routeFiles[$routeKey] = realpath($routesFile) ?: $routesFile;
305+
$realpath = realpath($routesFile);
306+
$this->routeFiles[$routeKey] = ($realpath === false) ? $routesFile : $realpath;
306307
}
307308
}
308309

@@ -1699,7 +1700,7 @@ public function resetRoutes()
16991700
*/
17001701
protected function loadRoutesOptions(?string $verb = null): array
17011702
{
1702-
$verb = $verb ?: $this->getHTTPVerb();
1703+
$verb ??= $this->getHTTPVerb();
17031704

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

0 commit comments

Comments
 (0)