Skip to content

Commit

Permalink
Recipe: phpstan/phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Nov 19, 2023
1 parent 8ff3aee commit b67c906
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 98 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
###> symfony/asset-mapper ###
/public/assets/
###< symfony/asset-mapper ###

###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"config": {
"allow-plugins": {
"symfony/flex": true,
"symfony/runtime": true
"symfony/runtime": true,
"phpstan/extension-installer": true
},
"sort-packages": true,
"optimize-autoloader": true,
Expand Down Expand Up @@ -123,11 +124,11 @@
"ekino/phpstan-banned-code": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpbench/phpbench": "^1.2",
"phpstan/phpstan": "^1.3",
"phpstan/phpstan-beberlei-assert": "^1.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.4",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^10.0",
"rector/rector": "^0.18",
Expand Down
96 changes: 45 additions & 51 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

216 changes: 216 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
parameters:
ignoreErrors:
-
message: "#^Method App\\\\ApiResource\\\\User\\:\\:createFrom\\(\\) has no return type specified\\.$#"
count: 1
path: src/ApiResource/User.php

-
message: "#^Parameter \\#1 \\$username of class App\\\\ApiResource\\\\User constructor expects string, string\\|null given\\.$#"
count: 1
path: src/ApiResource/User.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 2
path: src/Command/User/CreateUserCommand.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: src/Command/User/DemoteUserCommand.php

-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: non\\-falsy\\-string given\\.$#"
count: 1
path: src/Command/User/DemoteUserCommand.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: src/Command/User/PromoteUserCommand.php

-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: non\\-falsy\\-string given\\.$#"
count: 1
path: src/Command/User/PromoteUserCommand.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\City\\:\\:getGpsLat\\(\\)\\.$#"
count: 1
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\City\\:\\:getGpsLng\\(\\)\\.$#"
count: 1
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\City\\:\\:getId\\(\\)\\.$#"
count: 2
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\City\\:\\:getInseeCode\\(\\)\\.$#"
count: 2
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\City\\:\\:getName\\(\\)\\.$#"
count: 2
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\City\\:\\:getSlug\\(\\)\\.$#"
count: 1
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\City\\:\\:getZipCode\\(\\)\\.$#"
count: 2
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Department\\:\\:getCities\\(\\)\\.$#"
count: 1
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Department\\:\\:getCode\\(\\)\\.$#"
count: 1
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Department\\:\\:getId\\(\\)\\.$#"
count: 3
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Department\\:\\:getName\\(\\)\\.$#"
count: 1
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Department\\:\\:getSlug\\(\\)\\.$#"
count: 1
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Region\\:\\:getCode\\(\\)\\.$#"
count: 2
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Region\\:\\:getDepartments\\(\\)\\.$#"
count: 2
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Region\\:\\:getId\\(\\)\\.$#"
count: 2
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Region\\:\\:getName\\(\\)\\.$#"
count: 2
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method App\\\\Entity\\\\Region\\:\\:getSlug\\(\\)\\.$#"
count: 2
path: src/Controller/ApiController.php

-
message: "#^Call to an undefined method object\\:\\:setPassword\\(\\)\\.$#"
count: 1
path: src/Controller/ResetPasswordController.php

-
message: "#^Only booleans are allowed in a negated boolean, App\\\\Entity\\\\User\\|null given\\.$#"
count: 1
path: src/Controller/ResetPasswordController.php

-
message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#"
count: 1
path: src/Controller/ResetPasswordController.php

-
message: "#^Parameter \\#1 \\$emailFormData of method App\\\\Controller\\\\ResetPasswordController\\:\\:processSendingPasswordResetEmail\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/Controller/ResetPasswordController.php

-
message: "#^Parameter \\#1 \\$user of method Symfony\\\\Component\\\\PasswordHasher\\\\Hasher\\\\UserPasswordHasherInterface\\:\\:hashPassword\\(\\) expects Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\PasswordAuthenticatedUserInterface, object given\\.$#"
count: 1
path: src/Controller/ResetPasswordController.php

-
message: "#^Parameter \\#2 \\$plainPassword of method Symfony\\\\Component\\\\PasswordHasher\\\\Hasher\\\\UserPasswordHasherInterface\\:\\:hashPassword\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/Controller/ResetPasswordController.php

-
message: "#^Method App\\\\Entity\\\\ResetPasswordRequest\\:\\:getUser\\(\\) should return object but returns App\\\\Entity\\\\User\\|null\\.$#"
count: 1
path: src/Entity/ResetPasswordRequest.php

-
message: "#^Class App\\\\Form\\\\ChangePasswordFormType extends generic class Symfony\\\\Component\\\\Form\\\\AbstractType but does not specify its types\\: TData$#"
count: 1
path: src/Form/ChangePasswordFormType.php

-
message: "#^Class App\\\\Form\\\\ResetPasswordRequestFormType extends generic class Symfony\\\\Component\\\\Form\\\\AbstractType but does not specify its types\\: TData$#"
count: 1
path: src/Form/ResetPasswordRequestFormType.php

-
message: "#^Method App\\\\Repository\\\\CityRepository\\:\\:findByNameLike\\(\\) should return array\\<App\\\\Entity\\\\City\\> but returns mixed\\.$#"
count: 1
path: src/Repository/CityRepository.php

-
message: "#^Parameter \\#2 \\$user of class App\\\\Entity\\\\ResetPasswordRequest constructor expects App\\\\Entity\\\\User\\|null, object given\\.$#"
count: 1
path: src/Repository/ResetPasswordRequestRepository.php

-
message: "#^Class App\\\\Repository\\\\UserRepository implements generic interface Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\PasswordUpgraderInterface but does not specify its types\\: TUser$#"
count: 1
path: src/Repository/UserRepository.php

-
message: "#^Method App\\\\Repository\\\\UserRepository\\:\\:findOneByUsername\\(\\) should return App\\\\Entity\\\\User\\|null but returns mixed\\.$#"
count: 1
path: src/Repository/UserRepository.php

-
message: "#^Parameter \\#1 \\$password of class Symfony\\\\Component\\\\Security\\\\Http\\\\Authenticator\\\\Passport\\\\Credentials\\\\PasswordCredentials constructor expects string, bool\\|float\\|int\\|string given\\.$#"
count: 1
path: src/Security/UsernamePasswordAuthenticator.php

-
message: "#^Parameter \\#1 \\$userIdentifier of class Symfony\\\\Component\\\\Security\\\\Http\\\\Authenticator\\\\Passport\\\\Badge\\\\UserBadge constructor expects string, bool\\|float\\|int\\|string given\\.$#"
count: 1
path: src/Security/UsernamePasswordAuthenticator.php

-
message: "#^Parameter \\#2 \\$csrfToken of class Symfony\\\\Component\\\\Security\\\\Http\\\\Authenticator\\\\Passport\\\\Badge\\\\CsrfTokenBadge constructor expects string\\|null, bool\\|float\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Security/UsernamePasswordAuthenticator.php

-
message: "#^Call to an undefined method App\\\\Repository\\\\CityRepository\\:\\:findOneById\\(\\)\\.$#"
count: 1
path: src/State/MeasureStateProvider.php

-
message: "#^Class App\\\\State\\\\MeasureStateProvider implements generic interface ApiPlatform\\\\State\\\\ProviderInterface but does not specify its types\\: T$#"
count: 1
path: src/State/MeasureStateProvider.php

-
message: "#^Class App\\\\State\\\\UserDtoProvider implements generic interface ApiPlatform\\\\State\\\\ProviderInterface but does not specify its types\\: T$#"
count: 1
path: src/State/UserDtoProvider.php
13 changes: 13 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
level: max
paths:
- src
excludePaths:
- %currentWorkingDirectory%/src/Kernel.php
checkMissingIterableValueType: true
checkGenericClassInNonGenericObjectType: true
checkUninitializedProperties: true
treatPhpDocTypesAsCertain: false
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- phpstan-baseline.neon
Loading

0 comments on commit b67c906

Please sign in to comment.