diff --git a/tests/_support/Models/UserModel.php b/tests/_support/Models/UserModel.php index f940b5874ba5..8e3a1b34e13f 100644 --- a/tests/_support/Models/UserModel.php +++ b/tests/_support/Models/UserModel.php @@ -15,6 +15,9 @@ use CodeIgniter\Model; +/** + * @method int affectedRows() + */ class UserModel extends Model { protected $table = 'user'; diff --git a/tests/system/Models/FindModelTest.php b/tests/system/Models/FindModelTest.php index 43fb96d76b53..71a085dc3950 100644 --- a/tests/system/Models/FindModelTest.php +++ b/tests/system/Models/FindModelTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Exceptions\ModelException; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use stdClass; use Tests\Support\Entity\UserWithCasts; use Tests\Support\Models\JobModel; use Tests\Support\Models\SecondaryModel; @@ -115,7 +116,7 @@ public function testFindRespectsSoftDeletes(): void $this->createModel(UserModel::class); $user = $this->model->find(4); - $this->assertEmpty($user); + $this->assertNotInstanceOf(stdClass::class, $user); $user = $this->model->withDeleted()->find(4); $count = is_object($user) ? 1 : 0; diff --git a/tests/system/Models/LiveModelTestCase.php b/tests/system/Models/LiveModelTestCase.php index ad250ecc73b7..342daecdf302 100644 --- a/tests/system/Models/LiveModelTestCase.php +++ b/tests/system/Models/LiveModelTestCase.php @@ -52,6 +52,14 @@ protected function tearDown(): void /** * Create an instance of Model for use in testing. + * + * @template T of Model + * + * @param class-string $modelName + * + * @return T + * + * @phpstan-assert T $this->model */ protected function createModel(string $modelName, ?BaseConnection $db = null): Model { diff --git a/utils/phpstan-baseline/argument.type.neon b/utils/phpstan-baseline/argument.type.neon index 34a1a8c9986e..2d74da4c8139 100644 --- a/utils/phpstan-baseline/argument.type.neon +++ b/utils/phpstan-baseline/argument.type.neon @@ -1,4 +1,4 @@ -# total 136 errors +# total 135 errors parameters: ignoreErrors: @@ -247,11 +247,6 @@ parameters: count: 1 path: ../../tests/system/Models/UpdateModelTest.php - - - message: '#^Parameter \#1 \$row of method CodeIgniter\\BaseModel\:\:save\(\) expects array\\|object, list\\|null given\.$#' - count: 1 - path: ../../tests/system/Models/UpdateModelTest.php - - message: '#^Parameter \#1 \$format of method CodeIgniter\\RESTful\\ResourceController\:\:setFormat\(\) expects ''json''\|''xml'', ''Nonsense'' given\.$#' count: 1 diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 4cb13113bbe1..c978950648ed 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 3256 errors +# total 3234 errors includes: - argument.type.neon - assign.propertyType.neon @@ -25,4 +25,3 @@ includes: - property.phpDocType.neon - staticMethod.notFound.neon - ternary.shortNotAllowed.neon - - varTag.type.neon diff --git a/utils/phpstan-baseline/method.notFound.neon b/utils/phpstan-baseline/method.notFound.neon index 445f071fb3c2..8bc0b8ae54c0 100644 --- a/utils/phpstan-baseline/method.notFound.neon +++ b/utils/phpstan-baseline/method.notFound.neon @@ -1,4 +1,4 @@ -# total 82 errors +# total 81 errors parameters: ignoreErrors: @@ -152,11 +152,6 @@ parameters: count: 3 path: ../../tests/system/Images/GDHandlerTest.php - - - message: '#^Call to an undefined method CodeIgniter\\Model\:\:affectedRows\(\)\.$#' - count: 1 - path: ../../tests/system/Models/AffectedRowsTest.php - - message: '#^Call to an undefined method CodeIgniter\\Model\:\:getLastQuery\(\)\.$#' count: 1 diff --git a/utils/phpstan-baseline/property.nonObject.neon b/utils/phpstan-baseline/property.nonObject.neon index ccb1a0cb3f42..33d6299465f8 100644 --- a/utils/phpstan-baseline/property.nonObject.neon +++ b/utils/phpstan-baseline/property.nonObject.neon @@ -1,4 +1,4 @@ -# total 54 errors +# total 36 errors parameters: ignoreErrors: @@ -29,24 +29,9 @@ parameters: - message: '#^Cannot access property \$id on array\.$#' - count: 8 - path: ../../tests/system/Models/FindModelTest.php - - - - message: '#^Cannot access property \$name on array\.$#' - count: 5 - path: ../../tests/system/Models/FindModelTest.php - - - - message: '#^Cannot access property \$total on array\.$#' - count: 1 + count: 2 path: ../../tests/system/Models/FindModelTest.php - - - message: '#^Cannot access property \$country on array\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - message: '#^Cannot access property \$created_at on array\.$#' count: 3 @@ -59,16 +44,6 @@ parameters: - message: '#^Cannot access property \$description on array\.$#' - count: 3 - path: ../../tests/system/Models/SaveModelTest.php - - - - message: '#^Cannot access property \$id on array\.$#' - count: 1 - path: ../../tests/system/Models/SaveModelTest.php - - - - message: '#^Cannot access property \$name on array\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php @@ -94,7 +69,7 @@ parameters: - message: '#^Cannot access property \$value on list\\.$#' - count: 2 + count: 1 path: ../../tests/system/Models/UpdateModelTest.php - diff --git a/utils/phpstan-baseline/varTag.type.neon b/utils/phpstan-baseline/varTag.type.neon deleted file mode 100644 index 4be1089ace00..000000000000 --- a/utils/phpstan-baseline/varTag.type.neon +++ /dev/null @@ -1,13 +0,0 @@ -# total 2 errors - -parameters: - ignoreErrors: - - - message: '#^PHPDoc tag @var with type Tests\\Support\\Entity\\UserWithCasts is not subtype of type list\\|null\.$#' - count: 1 - path: ../../tests/system/Models/FindModelTest.php - - - - message: '#^PHPDoc tag @var with type stdClass is not subtype of type array\{\}\|null\.$#' - count: 1 - path: ../../tests/system/Models/UpdateModelTest.php