diff --git a/composer.json b/composer.json index 50371dc14671..902c2bd11065 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": "^1.1 || ^2.3", - "rector/rector": "2.0.10", + "rector/rector": "2.0.11", "shipmonk/phpstan-baseline-per-identifier": "^2.0" }, "replace": { diff --git a/rector.php b/rector.php index 7adec00da4bd..b8b5e1ccc73f 100644 --- a/rector.php +++ b/rector.php @@ -18,7 +18,6 @@ use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector; use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector; use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; -use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector; use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector; use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector; use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector; @@ -36,8 +35,8 @@ use Rector\Php70\Rector\FuncCall\RandomFunctionRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; 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\MethodCall\AssertCountWithZeroToAssertEmptyRector; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector; @@ -46,7 +45,6 @@ use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector; use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector; -use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector; use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; @@ -170,7 +168,7 @@ CompactToVariablesRector::class, - AssertCountWithZeroToAssertEmptyRector::class, + RemoveDataProviderParamKeysRector::class, ]) // auto import fully qualified class names ->withImportNames(removeUnusedImports: true) @@ -192,7 +190,6 @@ MakeInheritedMethodVisibilitySameAsParentRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, TernaryEmptyArrayArrayDimFetchToCoalesceRector::class, - EmptyOnNullableObjectToInstanceOfRector::class, DisallowedEmptyRuleFixerRector::class, PrivatizeFinalClassPropertyRector::class, BooleanInIfConditionRuleFixerRector::class, @@ -202,7 +199,6 @@ AddMethodCallBasedStrictParamTypeRector::class, TypedPropertyFromAssignsRector::class, ClosureReturnTypeRector::class, - FlipTypeControlToUseExclusiveTypeRector::class, AddArrowFunctionReturnTypeRector::class, ]) ->withConfiguredRule(StringClassNameToClassConstantRector::class, [ diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php index ca7819306e62..df2f217eb68a 100644 --- a/tests/system/CodeIgniterTest.php +++ b/tests/system/CodeIgniterTest.php @@ -19,6 +19,7 @@ use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\HTTP\Method; use CodeIgniter\HTTP\Response; +use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Router\RouteCollection; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Filters\CITestStreamFilter; @@ -95,6 +96,7 @@ public function testRunEmptyDefaultRouteReturnResponse(): void $_SERVER['argc'] = 1; $response = $this->codeigniter->run(null, true); + $this->assertInstanceOf(ResponseInterface::class, $response); $this->assertStringContainsString('Welcome to CodeIgniter', $response->getBody()); } @@ -159,6 +161,7 @@ public function testRun404OverrideControllerReturnsResponse(): void Services::injectMock('router', $router); $response = $this->codeigniter->run($routes, true); + $this->assertInstanceOf(ResponseInterface::class, $response); $this->assertStringContainsString('Oops', $response->getBody()); $this->assertSame(567, $response->getStatusCode()); @@ -177,6 +180,7 @@ public function testRun404OverrideReturnResponse(): void Services::injectMock('router', $router); $response = $this->codeigniter->run($routes, true); + $this->assertInstanceOf(ResponseInterface::class, $response); $this->assertStringContainsString('Oops', $response->getBody()); } @@ -467,6 +471,7 @@ public function testRunForceSecure(): void $this->assertNull($response->header('Location')); $response = $codeigniter->run(null, true); + $this->assertInstanceOf(ResponseInterface::class, $response); $this->assertSame('https://example.com/index.php/', $response->header('Location')->getValue()); } diff --git a/tests/system/Database/Live/OCI8/LastInsertIDTest.php b/tests/system/Database/Live/OCI8/LastInsertIDTest.php index 33945cf7d276..716cef2ff09d 100644 --- a/tests/system/Database/Live/OCI8/LastInsertIDTest.php +++ b/tests/system/Database/Live/OCI8/LastInsertIDTest.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Database\Live\OCI8; +use CodeIgniter\Database\BasePreparedQuery; use CodeIgniter\Database\Query; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; @@ -83,6 +84,7 @@ public function testGetInsertIDWithPreparedQuery(): void return (new Query($db))->setQuery($sql); }); + $this->assertInstanceOf(BasePreparedQuery::class, $query); $query->execute('foo', 'bar'); $actual = $this->db->insertID(); diff --git a/tests/system/HTTP/Files/FileCollectionTest.php b/tests/system/HTTP/Files/FileCollectionTest.php index 7be7fcfe546e..daebf98fc314 100644 --- a/tests/system/HTTP/Files/FileCollectionTest.php +++ b/tests/system/HTTP/Files/FileCollectionTest.php @@ -359,6 +359,7 @@ public function testErrorString(): void $collection = new FileCollection(); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $this->assertSame($expected, $file->getErrorString()); } @@ -379,6 +380,7 @@ public function testErrorStringWithUnknownError(): void $collection = new FileCollection(); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $this->assertSame($expected, $file->getErrorString()); } @@ -398,6 +400,7 @@ public function testErrorStringWithNoError(): void $collection = new FileCollection(); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $this->assertSame($expected, $file->getErrorString()); } @@ -416,6 +419,7 @@ public function testError(): void $collection = new FileCollection(); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $this->assertSame(UPLOAD_ERR_INI_SIZE, $file->getError()); } @@ -433,6 +437,7 @@ public function testErrorWithUnknownError(): void $collection = new FileCollection(); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $this->assertSame(0, $file->getError()); } @@ -451,6 +456,7 @@ public function testErrorWithNoError(): void $collection = new FileCollection(); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $this->assertSame(UPLOAD_ERR_OK, $file->getError()); } @@ -469,6 +475,7 @@ public function testClientPathReturnsValidFullPath(): void $collection = new FileCollection(); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $this->assertSame('someDir/someFile.txt', $file->getClientPath()); } @@ -486,6 +493,7 @@ public function testClientPathReturnsNullWhenFullPathIsNull(): void $collection = new FileCollection(); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $this->assertNull($file->getClientPath()); } diff --git a/tests/system/HTTP/Files/FileMovingTest.php b/tests/system/HTTP/Files/FileMovingTest.php index 9624ecd78a06..2d43c775f949 100644 --- a/tests/system/HTTP/Files/FileMovingTest.php +++ b/tests/system/HTTP/Files/FileMovingTest.php @@ -264,6 +264,7 @@ public function testInvalidFile(): void $this->expectException(HTTPException::class); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $file->move($destination, $file->getName(), false); } @@ -290,6 +291,7 @@ public function testFailedMoveBecauseOfWarning(): void $this->expectException(HTTPException::class); $file = $collection->getFile('userfile'); + $this->assertInstanceOf(UploadedFile::class, $file); $file->move($destination, $file->getName(), false); } @@ -321,6 +323,7 @@ public function testFailedMoveBecauseOfFalseReturned(): void $this->expectExceptionMessage('move_uploaded_file() returned false'); $file = $collection->getFile('userfile1'); + $this->assertInstanceOf(UploadedFile::class, $file); $file->move($destination, $file->getName(), false); } } diff --git a/tests/system/Test/ControllerTestTraitTest.php b/tests/system/Test/ControllerTestTraitTest.php index aa130ba85cab..44301afa376d 100644 --- a/tests/system/Test/ControllerTestTraitTest.php +++ b/tests/system/Test/ControllerTestTraitTest.php @@ -18,6 +18,7 @@ use CodeIgniter\Controller; use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Exceptions\RuntimeException; +use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\Log\Logger; use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use Config\App; @@ -161,6 +162,7 @@ public function testRequestPassthrough(): void ->execute('popper'); $req = $result->request(); + $this->assertInstanceOf(RequestInterface::class, $req); $this->assertSame('GET', $req->getMethod()); }