diff --git a/composer.json b/composer.json index 9cabb129ff8c..27b87b9e709c 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "phpunit/phpcov": "^9.0.2 || ^10.0", "phpunit/phpunit": "^10.5.16 || ^11.2", "predis/predis": "^3.0", - "rector/rector": "2.5.8", + "rector/rector": "2.5.9", "shipmonk/phpstan-baseline-per-identifier": "^2.0" }, "replace": { diff --git a/rector.php b/rector.php index cd5f3c21dd0f..856952b19206 100644 --- a/rector.php +++ b/rector.php @@ -33,10 +33,7 @@ use Rector\Php70\Rector\FuncCall\RandomFunctionRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; -use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; -use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; -use Rector\PHPUnit\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector; use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector; use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; @@ -107,13 +104,6 @@ // Keep property defaults for backward compatibility. RemoveDefaultValueFromAssignedPropertyRector::class, - ReadOnlyPropertyRector::class => [ - __DIR__ . '/system/Cache/ResponseCache.php', - __DIR__ . '/system/HotReloader/IteratorFilter.php', - __DIR__ . '/system/Router/RouteCollection.php', - __DIR__ . '/system/Security/Security.php', - ], - // Exclude test file because `is_cli()` is mocked and Rector might remove needed parameters. RemoveExtraParametersRector::class => [ __DIR__ . '/tests/system/Debug/ToolbarTest.php', @@ -160,19 +150,11 @@ __DIR__ . '/system/HTTP/SiteURI.php', ], - // Unnecessary (string) is inserted - NullToStrictStringFuncCallArgRector::class, - CompactToVariablesRector::class, // possibly isset() on purpose, on updated Config classes property across versions IssetOnPropertyObjectToPropertyExistsRector::class, - AssertFuncCallToPHPUnitAssertRector::class => [ - // use $this inside static closure - __DIR__ . '/tests/system/AutoReview/FrameworkCodeTest.php', - ], - // some tests extended by other tests FinalizeTestCaseClassRector::class, diff --git a/system/Router/Router.php b/system/Router/Router.php index 063bb5074cbb..1eda4c616d62 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -694,7 +694,7 @@ private function isValidSegment(string $segment): bool * Takes an array of URI segments as input and sets the class/method * to be called. * - * @param array $segments URI segments + * @param list $segments URI segments * * @return void */ @@ -705,13 +705,13 @@ protected function setRequest(array $segments = []) return; } - [$controller, $method] = array_pad(explode('::', $segments[0]), 2, null); + [$controller, $method] = explode('::', $segments[0], 2) + [null, null]; $this->controller = $controller; // $this->method already contains the default method name, // so don't overwrite it with emptiness. - if (! empty($method)) { + if ($method !== null && $method !== '') { $this->method = $method; } diff --git a/utils/phpstan-baseline/empty.notAllowed.neon b/utils/phpstan-baseline/empty.notAllowed.neon index 796292761d9c..9060c95a91ec 100644 --- a/utils/phpstan-baseline/empty.notAllowed.neon +++ b/utils/phpstan-baseline/empty.notAllowed.neon @@ -1,4 +1,4 @@ -# total 205 errors +# total 204 errors parameters: ignoreErrors: @@ -279,7 +279,7 @@ parameters: - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' - count: 2 + count: 1 path: ../../system/Router/Router.php - diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 03e4965a51a4..32ad4dacc2f5 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 1810 errors +# total 1808 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index 677e7101b2c3..28aeaabd8f58 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 1140 errors +# total 1139 errors parameters: ignoreErrors: @@ -3637,11 +3637,6 @@ parameters: count: 1 path: ../../system/Router/Router.php - - - message: '#^Method CodeIgniter\\Router\\Router\:\:setRequest\(\) has parameter \$segments with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - message: '#^Method CodeIgniter\\Router\\Router\:\:validateRequest\(\) has parameter \$segments with no value type specified in iterable type array\.$#' count: 1