diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 2fd4d79af642..3c2db54f7e4a 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -5143,18 +5143,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Entity/Entity.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Entity/Entity.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$original type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Entity/Entity.php', -]; $ignoreErrors[] = [ // identifier: codeigniter.configArgumentInstanceof 'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#', @@ -10987,12 +10975,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/_support/Entity/CustomUser.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property Tests\\\\Support\\\\Entity\\\\User\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/Entity/User.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Tests\\\\Support\\\\Language\\\\SecondMockLanguage\\:\\:loaded\\(\\) has no return type specified\\.$#', @@ -11227,12 +11209,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/_support/Models/UserModel.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property Tests\\\\Support\\\\SomeEntity\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/_support/SomeEntity.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method Tests\\\\Support\\\\Test\\\\TestForReflectionHelper\\:\\:getPrivate\\(\\) has no return type specified\\.$#', @@ -13717,180 +13693,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:getBar\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:getFakeBar\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:setBar\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.parameter - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:setBar\\(\\) has parameter \\$value with no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:_getBar\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:_setBar\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.parameter - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:_setBar\\(\\) has parameter \\$value with no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:getBar\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:setBar\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.parameter - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:setBar\\(\\) has parameter \\$value with no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.return - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1162\\:\\:getSimple\\(\\) has no return type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.parameter - 'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1229\\:\\:setSeventh\\(\\) has parameter \\$seventh with no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:\\$original type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:\\$original type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1162\\:\\:\\$_original has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1162\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1192\\:\\:\\$_original has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1192\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1211\\:\\:\\$_original has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1211\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1229\\:\\:\\$_original has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1229\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1287\\:\\:\\$_original has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1287\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1316\\:\\:\\$_original has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1316\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:895\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Entity/EntityTest.php', -]; $ignoreErrors[] = [ // identifier: codeigniter.configArgumentInstanceof 'message' => '#^Argument \\#1 \\$name \\(\'Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#', @@ -18661,12 +18463,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/system/View/ParserTest.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.iterableValue - 'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:370\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/View/ParserTest.php', -]; $ignoreErrors[] = [ // identifier: method.notFound 'message' => '#^Call to an undefined method CodeIgniter\\\\View\\\\Table\\:\\:compileTemplate\\(\\)\\.$#', diff --git a/system/Entity/Entity.php b/system/Entity/Entity.php index 5de8a42187a4..464992af6251 100644 --- a/system/Entity/Entity.php +++ b/system/Entity/Entity.php @@ -106,7 +106,7 @@ class Entity implements JsonSerializable /** * Holds the current values of all class vars. * - * @var array + * @var array */ protected $attributes = []; @@ -115,7 +115,7 @@ class Entity implements JsonSerializable * what's actually been changed and not accidentally write * nulls where we shouldn't. * - * @var array + * @var array */ protected $original = []; diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index 10947277926a..8dd7ceac31fa 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -1092,19 +1092,19 @@ protected function getEntity() 'createdAt' => 'created_at', ]; - public function setBar($value) + public function setBar(int|string $value): self { $this->attributes['bar'] = "bar:{$value}"; return $this; } - public function getBar() + public function getBar(): string { return "{$this->attributes['bar']}:bar"; } - public function getFakeBar() + public function getFakeBar(): string { return "{$this->attributes['bar']}:bar"; } @@ -1131,26 +1131,26 @@ protected function getNewSetterGetterEntity() ]; private string $bar; - public function setBar($value) + public function setBar(string $value): self { $this->bar = $value; return $this; } - public function getBar() + public function getBar(): string { return $this->bar; } - public function _setBar($value) + public function _setBar(string $value): self { $this->attributes['bar'] = "bar:{$value}"; return $this; } - public function _getBar() + public function _getBar(): string { return "{$this->attributes['bar']}:bar"; } @@ -1164,7 +1164,7 @@ protected function getMappedEntity() 'foo' => null, 'simple' => null, ]; - protected $_original = [ + protected $original = [ 'foo' => null, 'simple' => null, ]; @@ -1180,7 +1180,7 @@ protected function setSimple(string $val): void $this->attributes['simple'] = 'oo:' . $val; } - protected function getSimple() + protected function getSimple(): string { return $this->attributes['simple'] . ':oo'; } @@ -1194,7 +1194,7 @@ protected function getSwappedEntity() 'foo' => 'foo', 'bar' => 'bar', ]; - protected $_original = [ + protected $original = [ 'foo' => 'foo', 'bar' => 'bar', ]; @@ -1213,7 +1213,7 @@ protected function getSimpleSwappedEntity() 'foo' => 'foo', 'bar' => 'bar', ]; - protected $_original = [ + protected $original = [ 'foo' => 'foo', 'bar' => 'bar', ]; @@ -1242,7 +1242,7 @@ protected function getCastEntity($data = null): Entity 'twelfth' => null, 'thirteenth' => null, ]; - protected $_original = [ + protected $original = [ 'first' => null, 'second' => null, 'third' => null, @@ -1275,7 +1275,7 @@ protected function getCastEntity($data = null): Entity 'thirteenth' => 'uri', ]; - public function setSeventh($seventh): void + public function setSeventh(string $seventh): void { $this->attributes['seventh'] = $seventh; } @@ -1292,7 +1292,7 @@ protected function getCastNullableEntity() 'integer_0' => null, 'string_value_not_null' => 'value', ]; - protected $_original = [ + protected $original = [ 'string_null' => null, 'string_empty' => null, 'integer_null' => null, @@ -1320,7 +1320,7 @@ protected function getCustomCastEntity() 'third' => null, 'fourth' => null, ]; - protected $_original = [ + protected $original = [ 'first' => null, 'second' => null, 'third' => null,