diff --git a/phpstan-baseline.php b/phpstan-baseline.php index b6f2501b0..94be2606f 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -232,36 +232,6 @@ 'count' => 1, 'path' => __DIR__ . '/src/Database/Migrations/2020-12-28-223112_create_auth_tables.php', ]; -$ignoreErrors[] = [ - // identifier: method.childParameterType - 'message' => '#^Parameter \\#1 \\$value \\(bool\\|int\\|string\\) of method CodeIgniter\\\\Shield\\\\Entities\\\\Cast\\\\IntBoolCast\\:\\:set\\(\\) should be contravariant with parameter \\$value \\(array\\|bool\\|float\\|int\\|object\\|string\\|null\\) of method CodeIgniter\\\\Entity\\\\Cast\\\\BaseCast\\:\\:set\\(\\)$#', - 'count' => 1, - 'path' => __DIR__ . '/src/Entities/Cast/IntBoolCast.php', -]; -$ignoreErrors[] = [ - // identifier: method.childParameterType - 'message' => '#^Parameter \\#1 \\$value \\(bool\\|int\\|string\\) of method CodeIgniter\\\\Shield\\\\Entities\\\\Cast\\\\IntBoolCast\\:\\:set\\(\\) should be contravariant with parameter \\$value \\(array\\|bool\\|float\\|int\\|object\\|string\\|null\\) of method CodeIgniter\\\\Entity\\\\Cast\\\\CastInterface\\:\\:set\\(\\)$#', - 'count' => 1, - 'path' => __DIR__ . '/src/Entities/Cast/IntBoolCast.php', -]; -$ignoreErrors[] = [ - // identifier: method.childParameterType - 'message' => '#^Parameter \\#1 \\$value \\(int\\) of method CodeIgniter\\\\Shield\\\\Entities\\\\Cast\\\\IntBoolCast\\:\\:get\\(\\) should be contravariant with parameter \\$value \\(array\\|bool\\|float\\|int\\|object\\|string\\|null\\) of method CodeIgniter\\\\Entity\\\\Cast\\\\BaseCast\\:\\:get\\(\\)$#', - 'count' => 1, - 'path' => __DIR__ . '/src/Entities/Cast/IntBoolCast.php', -]; -$ignoreErrors[] = [ - // identifier: method.childParameterType - 'message' => '#^Parameter \\#1 \\$value \\(int\\) of method CodeIgniter\\\\Shield\\\\Entities\\\\Cast\\\\IntBoolCast\\:\\:get\\(\\) should be contravariant with parameter \\$value \\(array\\|bool\\|float\\|int\\|object\\|string\\|null\\) of method CodeIgniter\\\\Entity\\\\Cast\\\\CastInterface\\:\\:get\\(\\)$#', - 'count' => 1, - 'path' => __DIR__ . '/src/Entities/Cast/IntBoolCast.php', -]; -$ignoreErrors[] = [ - // identifier: property.phpDocType - 'message' => '#^PHPDoc type array\\ of property CodeIgniter\\\\Shield\\\\Entities\\\\Entity\\:\\:\\$castHandlers is not the same as PHPDoc type array\\ of overridden property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$castHandlers\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/src/Entities/Entity.php', -]; $ignoreErrors[] = [ // identifier: codeigniter.factoriesClassConstFetch 'message' => '#^Call to function model with CodeIgniter\\\\Shield\\\\Models\\\\GroupModel\\:\\:class is discouraged\\.$#', diff --git a/src/Entities/Cast/IntBoolCast.php b/src/Entities/Cast/IntBoolCast.php deleted file mode 100644 index 40c3bb2cf..000000000 --- a/src/Entities/Cast/IntBoolCast.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace CodeIgniter\Shield\Entities\Cast; - -use CodeIgniter\Entity\Cast\BaseCast; - -/** - * Int Bool Cast - * - * DB column: int (0/1) <--> Class property: bool - */ -final class IntBoolCast extends BaseCast -{ - /** - * @param int $value - */ - public static function get($value, array $params = []): bool - { - return (bool) $value; - } - - /** - * @param bool|int|string $value - */ - public static function set($value, array $params = []): int - { - return (int) $value; - } -} diff --git a/src/Entities/Entity.php b/src/Entities/Entity.php deleted file mode 100644 index f07416fdd..000000000 --- a/src/Entities/Entity.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace CodeIgniter\Shield\Entities; - -use CodeIgniter\Entity\Entity as FrameworkEntity; -use CodeIgniter\Shield\Entities\Cast\IntBoolCast; - -/** - * Base Entity - */ -abstract class Entity extends FrameworkEntity -{ - /** - * Custom convert handlers - * - * @var array - * @phpstan-var array - */ - protected $castHandlers = [ - 'int_bool' => IntBoolCast::class, - ]; -} diff --git a/src/Entities/Login.php b/src/Entities/Login.php index 785e3c79a..242ac2dec 100644 --- a/src/Entities/Login.php +++ b/src/Entities/Login.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Shield\Entities; +use CodeIgniter\Entity\Entity; + class Login extends Entity { /** @@ -20,6 +22,6 @@ class Login extends Entity */ protected $casts = [ 'date' => 'datetime', - 'success' => 'int_bool', + 'success' => 'int-bool', ]; } diff --git a/src/Entities/User.php b/src/Entities/User.php index c6c686575..8fef86822 100644 --- a/src/Entities/User.php +++ b/src/Entities/User.php @@ -14,6 +14,7 @@ namespace CodeIgniter\Shield\Entities; use CodeIgniter\Database\Exceptions\DataException; +use CodeIgniter\Entity\Entity; use CodeIgniter\I18n\Time; use CodeIgniter\Shield\Authentication\Authenticators\Session; use CodeIgniter\Shield\Authentication\Traits\HasAccessTokens; @@ -67,7 +68,7 @@ class User extends Entity */ protected $casts = [ 'id' => '?integer', - 'active' => 'int_bool', + 'active' => 'int-bool', 'permissions' => 'array', 'groups' => 'array', ]; diff --git a/src/Entities/UserIdentity.php b/src/Entities/UserIdentity.php index eed3f87db..88e54c29b 100644 --- a/src/Entities/UserIdentity.php +++ b/src/Entities/UserIdentity.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Shield\Entities; +use CodeIgniter\Entity\Entity; use CodeIgniter\I18n\Time; use CodeIgniter\Shield\Authentication\Passwords; @@ -41,7 +42,7 @@ class UserIdentity extends Entity */ protected $casts = [ 'id' => '?integer', - 'force_reset' => 'int_bool', + 'force_reset' => 'int-bool', ]; /**