diff --git a/composer.json b/composer.json index 5a186d786b4b..fb185514cf64 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.3.5", + "rector/rector": "2.3.6", "shipmonk/phpstan-baseline-per-identifier": "^2.0" }, "replace": { diff --git a/rector.php b/rector.php index 6fbb1f67d738..6f12a4d11c38 100644 --- a/rector.php +++ b/rector.php @@ -31,6 +31,7 @@ use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\Php70\Rector\FuncCall\RandomFunctionRector; +use Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; @@ -194,6 +195,10 @@ __DIR__ . '/tests/system/Database', __DIR__ . '/tests/system/Models', ], + + StaticCallOnNonStaticToInstanceCallRector::class => [ + __DIR__ . '/tests/_support/Config/Services.php', + ], ]) // auto import fully qualified class names ->withImportNames(removeUnusedImports: true) diff --git a/tests/system/API/ResponseTraitTest.php b/tests/system/API/ResponseTraitTest.php index a0196189493d..432d254abd40 100644 --- a/tests/system/API/ResponseTraitTest.php +++ b/tests/system/API/ResponseTraitTest.php @@ -753,7 +753,7 @@ public function testPaginateWithModel(): void public function testPaginateWithQueryBuilder(): void { // Mock the database and builder - $db = $this->createMock(BaseConnection::class); + $db = $this->createStub(BaseConnection::class); $builder = $this->getMockBuilder(BaseBuilder::class) ->setConstructorArgs(['test_table', $db]) @@ -1100,7 +1100,7 @@ public function testPaginateWithTransformerAndQueryBuilder(): void ]; // Mock the database and builder - $db = $this->createMock(BaseConnection::class); + $db = $this->createStub(BaseConnection::class); $builder = $this->getMockBuilder(BaseBuilder::class) ->setConstructorArgs(['test_table', $db]) diff --git a/tests/system/Models/SaveModelTest.php b/tests/system/Models/SaveModelTest.php index 193624f06857..bf283c4a6c52 100644 --- a/tests/system/Models/SaveModelTest.php +++ b/tests/system/Models/SaveModelTest.php @@ -22,6 +22,7 @@ use Tests\Support\Models\EntityModel; use Tests\Support\Models\JobModel; use Tests\Support\Models\SecondaryModel; +use Tests\Support\Models\SimpleEntity; use Tests\Support\Models\UserModel; use Tests\Support\Models\ValidModel; use Tests\Support\Models\WithoutAutoIncrementModel; @@ -173,6 +174,7 @@ public function testSelectAndEntitiesSaveOnlyChangedValues(): void $this->assertSame('Rocket Scientist', $job->name); $job->description = 'Some guitar description'; + $this->assertInstanceOf(SimpleEntity::class, $job); $this->model->save($job); $this->seeInDatabase('job', [ 'id' => $job->id, diff --git a/tests/system/Models/UpdateModelTest.php b/tests/system/Models/UpdateModelTest.php index 2495834ba978..7f0f6dd98527 100644 --- a/tests/system/Models/UpdateModelTest.php +++ b/tests/system/Models/UpdateModelTest.php @@ -696,6 +696,7 @@ public function testUpdateEntityUpdateOnlyChangedFalse(): void $user = $model->find(1); $updateAtBefore = $user->updated_at; + $this->assertInstanceOf(User::class, $user); // updates the Entity without changes. $result = $model->update(1, $user); diff --git a/utils/phpstan-baseline/missingType.property.neon b/utils/phpstan-baseline/missingType.property.neon index 2083602a9d54..b708adad5fab 100644 --- a/utils/phpstan-baseline/missingType.property.neon +++ b/utils/phpstan-baseline/missingType.property.neon @@ -318,72 +318,72 @@ parameters: path: ../../tests/system/Models/InsertModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:239\:\:\$_options has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:241\:\:\$_options has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:239\:\:\$country has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:241\:\:\$country has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:239\:\:\$created_at has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:241\:\:\$created_at has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:239\:\:\$deleted has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:241\:\:\$deleted has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:239\:\:\$email has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:241\:\:\$email has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:239\:\:\$id has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:241\:\:\$id has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:239\:\:\$name has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:241\:\:\$name has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:239\:\:\$updated_at has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:241\:\:\$updated_at has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:272\:\:\$_options has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:274\:\:\$_options has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:272\:\:\$created_at has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:274\:\:\$created_at has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:272\:\:\$id has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:274\:\:\$id has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:272\:\:\$name has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:274\:\:\$name has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:272\:\:\$updated_at has no type specified\.$#' + message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/SaveModelTest\.php\:274\:\:\$updated_at has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Property CodeIgniter\\Model@anonymous/tests/system/Models/SaveModelTest\.php\:288\:\:\$name has no type specified\.$#' + message: '#^Property CodeIgniter\\Model@anonymous/tests/system/Models/SaveModelTest\.php\:290\:\:\$name has no type specified\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php