diff --git a/composer.json b/composer.json index 49236ee763b5..57277bc5011b 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.2", + "rector/rector": "2.5.3", "shipmonk/phpstan-baseline-per-identifier": "^2.0" }, "replace": { diff --git a/rector.php b/rector.php index dcf59d665e7f..c3a1b22ad716 100644 --- a/rector.php +++ b/rector.php @@ -12,6 +12,7 @@ */ use Rector\Caching\ValueObject\Storage\FileCacheStorage; +use Rector\CodeQuality\Rector\BooleanNot\NegatedAndsToPositiveOrsRector; use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector; use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; @@ -22,6 +23,7 @@ use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector; use Rector\Config\RectorConfig; +use Rector\DeadCode\Rector\ClassMethod\RemoveDuplicatedReturnSelfDocblockRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector; @@ -36,7 +38,6 @@ use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; use Rector\PHPUnit\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector; use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector; -use Rector\PostRector\Rector\UnusedImportRemovingPostRector; use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; use Rector\Renaming\Rector\ConstFetch\RenameConstantRector; @@ -175,10 +176,9 @@ __DIR__ . '/tests/system/Models', ], - UnusedImportRemovingPostRector::class => [ - // buggy on auto import removed - __DIR__ . '/system/HTTP/Response.php', - ], + // to be applied in separate PRs to ease review + NegatedAndsToPositiveOrsRector::class, + RemoveDuplicatedReturnSelfDocblockRector::class, ]) // auto import fully qualified class names ->withImportNames() diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index ce87de3c356f..f1a9428c13eb 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -2686,7 +2686,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri $sql .= 'WHERE ' . implode( ' AND ', array_map( - static fn ($key, $value) => ( + static fn ($key, $value): RawSql|string => ( ($value instanceof RawSql && is_string($key)) ? $table . '.' . $key . ' = ' . $value @@ -2936,7 +2936,7 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri $sql .= 'ON ' . implode( ' AND ', array_map( - static fn ($key, $value) => ( + static fn ($key, $value): RawSql|string => ( $value instanceof RawSql ? $value : ( diff --git a/system/Database/MySQLi/Builder.php b/system/Database/MySQLi/Builder.php index a9e248fc4584..bba90421e9e4 100644 --- a/system/Database/MySQLi/Builder.php +++ b/system/Database/MySQLi/Builder.php @@ -92,7 +92,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri $sql .= 'ON ' . implode( ' AND ', array_map( - static fn ($key, $value) => ( + static fn ($key, $value): RawSql|string => ( ($value instanceof RawSql && is_string($key)) ? $table . '.' . $key . ' = ' . $value diff --git a/system/Database/OCI8/Builder.php b/system/Database/OCI8/Builder.php index 59195b3b533a..ff5b1289c34a 100644 --- a/system/Database/OCI8/Builder.php +++ b/system/Database/OCI8/Builder.php @@ -248,7 +248,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri $sql .= 'ON (' . implode( ' AND ', array_map( - static fn ($key, $value) => ( + static fn ($key, $value): RawSql|string => ( ($value instanceof RawSql && is_string($key)) ? $table . '.' . $key . ' = ' . $value @@ -353,7 +353,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri $sql .= implode( ' AND ', array_map( - static fn ($key, $value) => ( + static fn ($key, $value): RawSql|string => ( ($value instanceof RawSql && is_string($key)) ? $table . '.' . $key . ' = ' . $value @@ -442,7 +442,7 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri $sql .= 'WHERE ' . implode( ' AND ', array_map( - static fn ($key, $value) => ( + static fn ($key, $value): RawSql|string => ( $value instanceof RawSql ? $value : ( diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php index 098b08599808..cd7e7968fe72 100644 --- a/system/Database/SQLSRV/Builder.php +++ b/system/Database/SQLSRV/Builder.php @@ -752,7 +752,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri $sql .= implode( ' AND ', array_map( - static fn ($key, $value) => ( + static fn ($key, $value): RawSql|string => ( ($value instanceof RawSql && is_string($key)) ? $fullTableName . '.' . $key . ' = ' . $value diff --git a/tests/system/Test/FeatureTestTraitTest.php b/tests/system/Test/FeatureTestTraitTest.php index f36767f7f971..79a00104a079 100644 --- a/tests/system/Test/FeatureTestTraitTest.php +++ b/tests/system/Test/FeatureTestTraitTest.php @@ -412,7 +412,7 @@ public function testCallGetWithParams(): void [ 'GET', 'home', - static fn () => json_encode(service('request')->getGet()), + static fn (): false|string => json_encode(service('request')->getGet()), ], ]); $data = [ @@ -439,7 +439,7 @@ public function testCallGetWithParamsAndREQUEST(): void [ 'GET', 'home', - static fn () => json_encode(service('request')->fetchGlobal('request')), + static fn (): false|string => json_encode(service('request')->fetchGlobal('request')), ], ]); $data = [ @@ -466,7 +466,7 @@ public function testCallPostWithParams(): void [ 'POST', 'home', - static fn () => json_encode(service('request')->getPost()), + static fn (): false|string => json_encode(service('request')->getPost()), ], ]); $data = [ @@ -493,7 +493,7 @@ public function testCallPostWithParamsAndREQUEST(): void [ 'POST', 'home', - static fn () => json_encode(service('request')->fetchGlobal('request')), + static fn (): false|string => json_encode(service('request')->fetchGlobal('request')), ], ]); $data = [ @@ -544,7 +544,7 @@ public function testCallPutWithJsonRequestAndREQUEST(): void [ 'PUT', 'home', - static fn () => json_encode(service('request')->fetchGlobal('request')), + static fn (): false|string => json_encode(service('request')->fetchGlobal('request')), ], ]); $data = [