From 62001d27be565bc9fdb58ba5cc995ebd05670181 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Sep 2023 09:20:44 +0900 Subject: [PATCH 1/4] chore: composer require --dev phpstan/phpstan-strict-rules --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 11787a81e..cae646c7f 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "firebase/php-jwt": "^6.4", "rector/rector": "0.18.3", "codeigniter/phpstan-codeigniter": "^1.1", - "phpstan/extension-installer": "^1.3" + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan-strict-rules": "^1.5" }, "provide": { "codeigniter4/authentication-implementation": "1.0" From b8778dceb95bd21128323bdacbcfe14947392d4a Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Sep 2023 09:32:52 +0900 Subject: [PATCH 2/4] chore: enable some phpstan-strict-rules rules --- phpstan.neon.dist | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 976aa1e1a..f415fc148 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -24,3 +24,9 @@ parameters: - CodeIgniter\Shield\Config additionalServices: - CodeIgniter\Shield\Config\Services + strictRules: + allRules: false + disallowedLooseComparison: true + booleansInConditions: true + disallowedConstructs: true + matchingInheritedMethodNames: true From c113d05796b41e49e8d05df7fbf30757d87cab24 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Sep 2023 09:34:57 +0900 Subject: [PATCH 3/4] chore: update phpstan-baseline vendor/bin/phpstan analyze --generate-baseline phpstan-baseline.php --- phpstan-baseline.php | 275 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 275 insertions(+) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 7400fdd6f..4a1a11d17 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -1,18 +1,158 @@ '#^Call to function property_exists\\(\\) with CodeIgniter\\\\Shield\\\\Config\\\\Auth and \'userProvider\' will always evaluate to true\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Auth.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Auth.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Only booleans are allowed in a ternary operator condition, CodeIgniter\\\\Shield\\\\Entities\\\\User\\|null given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Auth.php', +]; $ignoreErrors[] = [ 'message' => '#^Call to deprecated function random_string\\(\\)\\: The type \'basic\', \'md5\', and \'sha1\' are deprecated\\. They are not cryptographically secure\\.$#', 'count' => 1, 'path' => __DIR__ . '/src/Authentication/Actions/Email2FA.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 2, + 'path' => __DIR__ . '/src/Authentication/Actions/Email2FA.php', +]; $ignoreErrors[] = [ 'message' => '#^Call to deprecated function random_string\\(\\)\\: The type \'basic\', \'md5\', and \'sha1\' are deprecated\\. They are not cryptographically secure\\.$#', 'count' => 1, 'path' => __DIR__ . '/src/Authentication/Actions/EmailActivator.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Authentication.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 4, + 'path' => __DIR__ . '/src/Authentication/Authenticators/AccessTokens.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Only booleans are allowed in &&, CodeIgniter\\\\I18n\\\\Time\\|null given on the left side\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Authenticators/AccessTokens.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#1 \\$credentials \\(array\\{token\\?\\: string\\}\\) of method CodeIgniter\\\\Shield\\\\Authentication\\\\Authenticators\\\\JWT\\:\\:attempt\\(\\) should be contravariant with parameter \\$credentials \\(array\\) of method CodeIgniter\\\\Shield\\\\Authentication\\\\AuthenticatorInterface\\:\\:attempt\\(\\)$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Authenticators/JWT.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#1 \\$credentials \\(array\\{token\\?\\: string\\}\\) of method CodeIgniter\\\\Shield\\\\Authentication\\\\Authenticators\\\\JWT\\:\\:check\\(\\) should be contravariant with parameter \\$credentials \\(array\\) of method CodeIgniter\\\\Shield\\\\Authentication\\\\AuthenticatorInterface\\:\\:check\\(\\)$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Authenticators/JWT.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 3, + 'path' => __DIR__ . '/src/Authentication/Authenticators/Session.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Only booleans are allowed in an elseif condition, string\\|null given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Authenticators/Session.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Only booleans are allowed in an if condition, CodeIgniter\\\\Shield\\\\Entities\\\\UserIdentity\\|null given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Authenticators/Session.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Only booleans are allowed in an if condition, int\\|string\\|null given\\.$#', + 'count' => 3, + 'path' => __DIR__ . '/src/Authentication/Authenticators/Session.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#1 \\$credentials \\(array\\{email\\?\\: string, username\\?\\: string, password\\?\\: string\\}\\) of method CodeIgniter\\\\Shield\\\\Authentication\\\\Authenticators\\\\Session\\:\\:attempt\\(\\) should be contravariant with parameter \\$credentials \\(array\\) of method CodeIgniter\\\\Shield\\\\Authentication\\\\AuthenticatorInterface\\:\\:attempt\\(\\)$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Authenticators/Session.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#1 \\$credentials \\(array\\{email\\?\\: string, username\\?\\: string, password\\?\\: string\\}\\) of method CodeIgniter\\\\Shield\\\\Authentication\\\\Authenticators\\\\Session\\:\\:check\\(\\) should be contravariant with parameter \\$credentials \\(array\\) of method CodeIgniter\\\\Shield\\\\Authentication\\\\AuthenticatorInterface\\:\\:check\\(\\)$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Authenticators/Session.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Call to method CodeIgniter\\\\Shield\\\\Result\\:\\:isOK\\(\\) with incorrect case\\: isOk$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Passwords.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Passwords.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Passwords/CompositionValidator.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 5, + 'path' => __DIR__ . '/src/Authentication/Passwords/NothingPersonalValidator.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Call to method CodeIgniter\\\\Shield\\\\Result\\:\\:isOK\\(\\) with incorrect case\\: isOk$#', + 'count' => 2, + 'path' => __DIR__ . '/src/Authentication/Passwords/ValidationRules.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Passwords/ValidationRules.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Only booleans are allowed in &&, CodeIgniter\\\\Shield\\\\Entities\\\\User\\|null given on the right side\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Authentication/Passwords/ValidationRules.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 3, + 'path' => __DIR__ . '/src/Authorization/Groups.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Return type \\(int\\|string\\|null\\) of method CodeIgniter\\\\Shield\\\\Collectors\\\\Auth\\:\\:getBadgeValue\\(\\) should be covariant with return type \\(int\\|null\\) of method CodeIgniter\\\\Debug\\\\Toolbar\\\\Collectors\\\\BaseCollector\\:\\:getBadgeValue\\(\\)$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Collectors/Auth.php', +]; +$ignoreErrors[] = [ + 'message' => '#^PHPDoc type array\\ of property CodeIgniter\\\\Shield\\\\Commands\\\\Generators\\\\UserModelGenerator\\:\\:\\$arguments is not the same as PHPDoc type array of overridden property CodeIgniter\\\\CLI\\\\BaseCommand\\:\\:\\$arguments\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Commands/Generators/UserModelGenerator.php', +]; +$ignoreErrors[] = [ + 'message' => '#^PHPDoc type array\\ of property CodeIgniter\\\\Shield\\\\Commands\\\\Generators\\\\UserModelGenerator\\:\\:\\$options is not the same as PHPDoc type array of overridden property CodeIgniter\\\\CLI\\\\BaseCommand\\:\\:\\$options\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Commands/Generators/UserModelGenerator.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Controllers/ActionController.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Instanceof between CodeIgniter\\\\Shield\\\\Authentication\\\\Actions\\\\ActionInterface and CodeIgniter\\\\Shield\\\\Authentication\\\\Actions\\\\ActionInterface will always evaluate to true\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Controllers/ActionController.php', +]; $ignoreErrors[] = [ 'message' => '#^Call to deprecated function random_string\\(\\)\\: The type \'basic\', \'md5\', and \'sha1\' are deprecated\\. They are not cryptographically secure\\.$#', @@ -44,11 +184,66 @@ 'count' => 1, 'path' => __DIR__ . '/src/Database/Migrations/2020-12-28-223112_create_auth_tables.php', ]; +$ignoreErrors[] = [ + '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[] = [ + '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[] = [ + '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[] = [ + '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[] = [ + '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[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 2, + 'path' => __DIR__ . '/src/Entities/Group.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 8, + 'path' => __DIR__ . '/src/Entities/User.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, max\\> given\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Entities/User.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Filters/AbstractAuthFilter.php', +]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Shield\\\\Filters\\\\AuthRates\\:\\:before\\(\\) should return CodeIgniter\\\\HTTP\\\\RedirectResponse\\|void but returns CodeIgniter\\\\HTTP\\\\ResponseInterface\\.$#', 'count' => 1, 'path' => __DIR__ . '/src/Filters/AuthRates.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Call to method CodeIgniter\\\\HTTP\\\\ResponseInterface\\:\\:setJSON\\(\\) with incorrect case\\: setJson$#', + 'count' => 2, + 'path' => __DIR__ . '/src/Filters/TokenAuth.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Filters/TokenAuth.php', +]; $ignoreErrors[] = [ 'message' => '#^Method CodeIgniter\\\\Shield\\\\Filters\\\\TokenAuth\\:\\:before\\(\\) should return CodeIgniter\\\\HTTP\\\\RedirectResponse\\|void but returns CodeIgniter\\\\HTTP\\\\ResponseInterface\\.$#', 'count' => 2, @@ -76,21 +271,81 @@ 'count' => 1, 'path' => __DIR__ . '/src/Models/UserIdentityModel.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 2, + 'path' => __DIR__ . '/src/Models/UserModel.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#1 \\$data \\(array\\|CodeIgniter\\\\Shield\\\\Entities\\\\User\\) of method CodeIgniter\\\\Shield\\\\Models\\\\UserModel\\:\\:insert\\(\\) should be contravariant with parameter \\$data \\(array\\|object\\|null\\) of method CodeIgniter\\\\Model\\:\\:insert\\(\\)$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Models/UserModel.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#1 \\$data \\(array\\|CodeIgniter\\\\Shield\\\\Entities\\\\User\\) of method CodeIgniter\\\\Shield\\\\Models\\\\UserModel\\:\\:save\\(\\) should be contravariant with parameter \\$data \\(array\\|object\\) of method CodeIgniter\\\\BaseModel\\:\\:save\\(\\)$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Models/UserModel.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Parameter \\#2 \\$data \\(array\\|CodeIgniter\\\\Shield\\\\Entities\\\\User\\) of method CodeIgniter\\\\Shield\\\\Models\\\\UserModel\\:\\:update\\(\\) should be contravariant with parameter \\$data \\(array\\|object\\|null\\) of method CodeIgniter\\\\Model\\:\\:update\\(\\)$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Models/UserModel.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Return type \\(int\\|string\\|true\\) of method CodeIgniter\\\\Shield\\\\Models\\\\UserModel\\:\\:insert\\(\\) should be covariant with return type \\(int\\|object\\|string\\|false\\) of method CodeIgniter\\\\Model\\:\\:insert\\(\\)$#', + 'count' => 1, + 'path' => __DIR__ . '/src/Models/UserModel.php', +]; $ignoreErrors[] = [ 'message' => '#^Cannot access property \\$id on array\\|object\\.$#', 'count' => 2, 'path' => __DIR__ . '/tests/Authentication/AuthHelperTest.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'CodeIgniter\\\\\\\\Shield\\\\\\\\Result\' and CodeIgniter\\\\Shield\\\\Result will always evaluate to true\\.$#', + 'count' => 2, + 'path' => __DIR__ . '/tests/Authentication/Authenticators/AccessTokenAuthenticatorTest.php', +]; $ignoreErrors[] = [ 'message' => '#^Cannot access property \\$id on array\\|object\\.$#', 'count' => 2, 'path' => __DIR__ . '/tests/Authentication/Authenticators/AccessTokenAuthenticatorTest.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'CodeIgniter\\\\\\\\Shield\\\\\\\\Result\' and CodeIgniter\\\\Shield\\\\Result will always evaluate to true\\.$#', + 'count' => 3, + 'path' => __DIR__ . '/tests/Authentication/Authenticators/JWTAuthenticatorTest.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'CodeIgniter\\\\\\\\Shield\\\\\\\\Result\' and CodeIgniter\\\\Shield\\\\Result will always evaluate to true\\.$#', + 'count' => 9, + 'path' => __DIR__ . '/tests/Authentication/Authenticators/SessionAuthenticatorTest.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/tests/Authentication/Filters/AbstractFilterTestCase.php', +]; $ignoreErrors[] = [ 'message' => '#^Cannot access property \\$id on array\\|object\\.$#', 'count' => 6, 'path' => __DIR__ . '/tests/Authentication/Filters/SessionFilterTest.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Implicit array creation is not allowed \\- variable \\$users might not exist\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/tests/Authentication/ForcePasswordResetTest.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Variable \\$users might not be defined\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/tests/Authentication/ForcePasswordResetTest.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'CodeIgniter\\\\\\\\Shield\\\\\\\\Entities\\\\\\\\AccessToken\' and CodeIgniter\\\\Shield\\\\Entities\\\\AccessToken will always evaluate to true\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/tests/Authentication/HasAccessTokensTest.php', +]; $ignoreErrors[] = [ 'message' => '#^Cannot access property \\$id on array\\|object\\.$#', 'count' => 2, @@ -101,6 +356,16 @@ 'count' => 4, 'path' => __DIR__ . '/tests/Authorization/AuthorizableTest.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Only booleans are allowed in a ternary operator condition, string\\|null given\\.$#', + 'count' => 2, + 'path' => __DIR__ . '/tests/Language/AbstractTranslationTestCase.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsString\\(\\) with string will always evaluate to true\\.$#', + 'count' => 6, + 'path' => __DIR__ . '/tests/Unit/Authentication/JWT/JWTManagerTest.php', +]; $ignoreErrors[] = [ 'message' => '#^Cannot access property \\$id on array\\|object\\.$#', 'count' => 1, @@ -111,6 +376,11 @@ 'count' => 1, 'path' => __DIR__ . '/tests/Unit/UserTest.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'CodeIgniter\\\\\\\\Shield\\\\\\\\Entities\\\\\\\\UserIdentity\' and CodeIgniter\\\\Shield\\\\Entities\\\\UserIdentity will always evaluate to true\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/tests/Unit/UserTest.php', +]; $ignoreErrors[] = [ 'message' => '#^Cannot access property \\$active on array\\|object\\.$#', 'count' => 2, @@ -131,5 +401,10 @@ 'count' => 1, 'path' => __DIR__ . '/tests/Unit/UserTest.php', ]; +$ignoreErrors[] = [ + 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/tests/_support/Config/Registrar.php', +]; return ['parameters' => ['ignoreErrors' => $ignoreErrors]]; From 3aaca031d1f3715d09fb67472673fbdedf593537 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Sep 2023 09:41:40 +0900 Subject: [PATCH 4/4] chore: add phpstan-strict-rules/rules.neon to phpstanConfigs() --- rector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rector.php b/rector.php index 082ce9de7..78ede225f 100644 --- a/rector.php +++ b/rector.php @@ -67,6 +67,7 @@ $rectorConfig->phpstanConfigs([ __DIR__ . '/phpstan.neon.dist', __DIR__ . '/vendor/codeigniter/phpstan-codeigniter/extension.neon', + __DIR__ . '/vendor/phpstan/phpstan-strict-rules/rules.neon', ]); // Set the target version for refactoring