diff --git a/composer.json b/composer.json index ff8aee6027c4..e29e5dcd9c33 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "phpunit/phpcov": "^9.0.2 || ^10.0", "phpunit/phpunit": "^10.5.16 || ^11.2", "predis/predis": "^3.0", - "rector/rector": "2.2.4", + "rector/rector": "2.2.5", "shipmonk/phpstan-baseline-per-identifier": "^2.0" }, "replace": { diff --git a/rector.php b/rector.php index f2aed4ac2969..e5b29eead7ff 100644 --- a/rector.php +++ b/rector.php @@ -36,6 +36,7 @@ use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\RemoveDataProviderParamKeysRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; +use Rector\PHPUnit\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector; @@ -172,6 +173,11 @@ // needs separate PR for activation to allow more depth review FunctionLikeToFirstClassCallableRector::class, + + AssertFuncCallToPHPUnitAssertRector::class => [ + // use $this inside static closure + __DIR__ . '/tests/system/AutoReview/FrameworkCodeTest.php', + ], ]) // auto import fully qualified class names ->withImportNames(removeUnusedImports: true) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 7379d014cc09..feb161bdfc92 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1574,7 +1574,7 @@ private function checkHostname($hostname): bool // Has multiple hostnames if (is_array($hostname)) { - $hostnameLower = array_map('strtolower', $hostname); + $hostnameLower = array_map(strtolower(...), $hostname); return in_array(strtolower($this->httpHost), $hostnameLower, true); } diff --git a/tests/system/CommonSingleServiceTest.php b/tests/system/CommonSingleServiceTest.php index f3e3bb57b40b..014ac12a27fc 100644 --- a/tests/system/CommonSingleServiceTest.php +++ b/tests/system/CommonSingleServiceTest.php @@ -37,7 +37,7 @@ public function testSingleServiceWithNoParamsSupplied(string $service): void $service1 = single_service($service); // @phpstan-ignore codeigniter.unknownServiceMethod $service2 = single_service($service); // @phpstan-ignore codeigniter.unknownServiceMethod - assert($service1 !== null); + $this->assertNotNull($service1); $this->assertInstanceOf($service1::class, $service2); $this->assertNotSame($service1, $service2); @@ -65,7 +65,7 @@ public function testSingleServiceWithAtLeastOneParamSupplied(string $service): v $service1 = single_service($service, ...$params); // @phpstan-ignore codeigniter.unknownServiceMethod $service2 = single_service($service, ...$params); // @phpstan-ignore codeigniter.unknownServiceMethod - assert($service1 !== null); + $this->assertNotNull($service1); $this->assertInstanceOf($service1::class, $service2); $this->assertNotSame($service1, $service2); @@ -120,8 +120,8 @@ public function testSingleServiceWithAllParamsSupplied(): void $cache1 = single_service('cache', null, true); $cache2 = single_service('cache', null, true); - assert($cache1 !== null); - assert($cache2 !== null); + $this->assertNotNull($cache1); + $this->assertNotNull($cache2); // Assert that even passing true as last param this will // not create a shared instance.