diff --git a/tests/system/Models/InsertModelTest.php b/tests/system/Models/InsertModelTest.php index baf6b45ea7f0..0442cd945e19 100644 --- a/tests/system/Models/InsertModelTest.php +++ b/tests/system/Models/InsertModelTest.php @@ -19,6 +19,7 @@ use CodeIgniter\I18n\Time; use CodeIgniter\Model; use Config\Database; +use DateTimeInterface; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use stdClass; @@ -194,13 +195,17 @@ public function testInsertResultFail(): void public function testInsertBatchNewEntityWithDateTime(): void { $entity = new class () extends Entity { - protected $id; - protected $name; - protected $email; - protected $country; - protected $deleted; - protected $created_at; - protected $updated_at; + protected int $id; + protected string $name; + protected string $email; + protected string $country; + protected bool $deleted; + protected DateTimeInterface $created_at; + protected DateTimeInterface $updated_at; + + /** + * @var array{'datamap': array{}, 'dates': array{string, string, string}, 'casts': array{}} + */ protected $_options = [ 'datamap' => [], 'dates' => [ @@ -288,13 +293,17 @@ public function testInsertEntityWithNoDataExceptionNoAllowedData(): void $this->createModel(UserModel::class); $entity = new class () extends Entity { - protected $id; - protected $name; - protected $email; - protected $country; - protected $deleted; - protected $created_at; - protected $updated_at; + protected int $id; + protected string $name; + protected string $email; + protected string $country; + protected bool $deleted; + protected DateTimeInterface $created_at; + protected DateTimeInterface $updated_at; + + /** + * @var array{'datamap': array{}, 'dates': array{string, string, string}, 'casts': array{}} + */ protected $_options = [ 'datamap' => [], 'dates' => [ diff --git a/tests/system/Models/SaveModelTest.php b/tests/system/Models/SaveModelTest.php index bf283c4a6c52..654702dd4ea3 100644 --- a/tests/system/Models/SaveModelTest.php +++ b/tests/system/Models/SaveModelTest.php @@ -17,6 +17,7 @@ use CodeIgniter\Entity\Entity; use CodeIgniter\I18n\Time; use CodeIgniter\Model; +use DateTimeInterface; use PHPUnit\Framework\Attributes\Group; use stdClass; use Tests\Support\Models\EntityModel; @@ -239,13 +240,17 @@ public function testEmptySaveData(): void public function testSaveNewEntityWithDateTime(): void { $entity = new class () extends Entity { - protected $id; - protected $name; - protected $email; - protected $country; - protected $deleted; - protected $created_at; - protected $updated_at; + protected int $id; + protected string $name; + protected string $email; + protected string $country; + protected bool $deleted; + protected DateTimeInterface $created_at; + protected DateTimeInterface $updated_at; + + /** + * @var array{'datamap': array{}, 'dates': array{string, string, string}, 'casts': array{}} + */ protected $_options = [ 'datamap' => [], 'dates' => [ @@ -272,10 +277,14 @@ public function testSaveNewEntityWithDateTime(): void public function testSaveNewEntityWithDate(): void { $entity = new class () extends Entity { - protected $id; - protected $name; - protected $created_at; - protected $updated_at; + protected int $id; + protected string $name; + protected DateTimeInterface $created_at; + protected DateTimeInterface $updated_at; + + /** + * @var array{'datamap': array{}, 'dates': array{string, string, string}, 'casts': array{}} + */ protected $_options = [ 'datamap' => [], 'dates' => [ @@ -295,7 +304,7 @@ public function testSaveNewEntityWithDate(): void protected $returnType = 'object'; protected $useSoftDeletes = true; protected $dateFormat = 'date'; - public $name = ''; + public string $name = ''; }; $entity->name = 'Mark'; diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 1bc172390faa..c065fa299fd3 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 2092 errors +# total 2062 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/missingType.property.neon b/utils/phpstan-baseline/missingType.property.neon index 66f4f74b5ff3..451773e8bc5d 100644 --- a/utils/phpstan-baseline/missingType.property.neon +++ b/utils/phpstan-baseline/missingType.property.neon @@ -1,4 +1,4 @@ -# total 77 errors +# total 47 errors parameters: ignoreErrors: @@ -236,153 +236,3 @@ parameters: message: '#^Property CodeIgniter\\Database\\Live\\MySQLi\\NumberNativeTest\:\:\$tests has no type specified\.$#' count: 1 path: ../../tests/system/Database/Live/MySQLi/NumberNativeTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:196\:\:\$_options has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:196\:\:\$country has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:196\:\:\$created_at has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:196\:\:\$deleted has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:196\:\:\$email has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:196\:\:\$id has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:196\:\:\$name has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:196\:\:\$updated_at has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:290\:\:\$_options has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:290\:\:\$country has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:290\:\:\$created_at has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:290\:\:\$deleted has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:290\:\:\$email has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:290\:\:\$id has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:290\:\:\$name has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - message: '#^Property CodeIgniter\\Entity\\Entity@anonymous/tests/system/Models/InsertModelTest\.php\:290\:\:\$updated_at has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/InsertModelTest.php - - - - 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\: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\: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\: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\: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\: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\: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\: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\: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\: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\: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\: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\: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\:290\:\:\$name has no type specified\.$#' - count: 1 - path: ../../tests/system/Models/SaveModelTest.php