Skip to content

Commit

Permalink
Improve phpstan config, add baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
TamasSzigeti committed Jun 20, 2021
1 parent 0532bbc commit 498296d
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/var
/cache
.phpunit.result.cache
.phpstan-cache
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"phpstan/phpstan": "^0.12.25",
"beberlei/porpaginas": "^1.2",
"php-coveralls/php-coveralls": "^2.1.0",
"symfony/phpunit-bridge": "^4.1.9 | ^5.1"
"symfony/phpunit-bridge": "^4.1.9 | ^5.1",
"thecodingmachine/phpstan-strict-rules": "^0.12.1"
},
"scripts": {
"phpstan": "phpstan analyse GraphqliteBundle.php DependencyInjection/ Controller/ Resources/ Security/ -c phpstan.neon --level=7 --no-progress"
Expand Down
162 changes: 162 additions & 0 deletions phpstan.baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
parameters:
ignoreErrors:
-
message: "#^Anonymous function should have native return typehint \"array\"\\.$#"
count: 1
path: Controller/GraphqliteController.php

-
message: "#^Instanceof between GraphQL\\\\Executor\\\\Promise\\\\Promise and GraphQL\\\\Executor\\\\Promise\\\\Promise will always evaluate to true\\.$#"
count: 1
path: Controller/GraphqliteController.php

-
message: "#^Anonymous function should have native return typehint \"array\"\\.$#"
count: 1
path: DependencyInjection/GraphqliteCompilerPass.php

-
message: "#^Argument of an invalid type array\\|bool\\|float\\|int\\|string\\|null supplied for foreach, only iterables are supported\\.$#"
count: 3
path: DependencyInjection/GraphqliteCompilerPass.php

-
message: "#^Binary operation \"\\.\" between 'security\\.firewall…' and array\\|bool\\|float\\|int\\|string\\|null results in an error\\.$#"
count: 2
path: DependencyInjection/GraphqliteCompilerPass.php

-
message: "#^Cannot cast \\(array&nonEmpty\\)\\|float\\|int\\<min, \\-1\\>\\|int\\<1, max\\>\\|string\\|true to int\\.$#"
count: 2
path: DependencyInjection/GraphqliteCompilerPass.php

-
message: "#^Negated boolean expression is always true\\.$#"
count: 1
path: DependencyInjection/GraphqliteCompilerPass.php

-
message: "#^Property TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\DependencyInjection\\\\GraphqliteCompilerPass\\:\\:\\$cacheDir \\(string\\) does not accept array\\|bool\\|float\\|int\\|string\\|null\\.$#"
count: 1
path: DependencyInjection/GraphqliteCompilerPass.php

-
message: "#^Anonymous function should have native return typehint \"string\"\\.$#"
count: 2
path: DependencyInjection/GraphqliteExtension.php

-
message: "#^Method TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\DependencyInjection\\\\GraphqliteExtension\\:\\:getNamespaceDir\\(\\) is unused\\.$#"
count: 1
path: DependencyInjection/GraphqliteExtension.php

-
message: "#^Class Overblog\\\\GraphiQLBundle\\\\Config\\\\GraphQLEndpoint\\\\RootResolver referenced with incorrect case\\: Overblog\\\\GraphiQLBundle\\\\Config\\\\GraphqlEndpoint\\\\RootResolver\\.$#"
count: 1
path: DependencyInjection/OverblogGraphiQLEndpointWiringPass.php

-
message: "#^Call to static method forSchemaAndResolver\\(\\) on an unknown class TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\GraphiQL\\\\GraphQLEndpointInvalidSchemaException\\.$#"
count: 1
path: GraphiQL/EndpointResolver.php

-
message: "#^Property TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\GraphiQL\\\\EndpointResolver\\:\\:\\$requestStack has no typehint specified\\.$#"
count: 1
path: GraphiQL/EndpointResolver.php

-
message: "#^Call to an undefined method ReflectionType\\:\\:getName\\(\\)\\.$#"
count: 1
path: Mappers/RequestParameterMiddleware.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, array\\<GraphQL\\\\Validator\\\\Rules\\\\ValidationRule\\>\\|\\(callable\\) given\\.$#"
count: 1
path: Server/ServerConfig.php

-
message: "#^Method TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\Fixtures\\\\Controller\\\\TestGraphqlController\\:\\:contacts\\(\\) return type has no value type specified in iterable type Porpaginas\\\\Arrays\\\\ArrayResult\\.$#"
count: 1
path: Tests/Fixtures/Controller/TestGraphqlController.php

-
message: "#^PHPDoc tag @return with type array\\<TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\Fixtures\\\\Entities\\\\Contact\\> is incompatible with native type Porpaginas\\\\Arrays\\\\ArrayResult\\.$#"
count: 1
path: Tests/Fixtures/Controller/TestGraphqlController.php

-
message: "#^Method TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\Fixtures\\\\Entities\\\\Contact\\:\\:injectServicePrefetch\\(\\) has parameter \\$prefetchData with no typehint specified\\.$#"
count: 1
path: Tests/Fixtures/Entities/Contact.php

-
message: "#^Method TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\Fixtures\\\\Entities\\\\Contact\\:\\:prefetchData\\(\\) has no return typehint specified\\.$#"
count: 1
path: Tests/Fixtures/Entities/Contact.php

-
message: "#^Method TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\Fixtures\\\\Entities\\\\Contact\\:\\:prefetchData\\(\\) has parameter \\$iterable with no value type specified in iterable type iterable\\.$#"
count: 1
path: Tests/Fixtures/Entities/Contact.php

-
message: "#^Cannot call method assertValid\\(\\) on object\\|null\\.$#"
count: 2
path: Tests/FunctionalTest.php

-
message: "#^Cannot call method handleRequest\\(\\) on object\\|null\\.$#"
count: 1
path: Tests/FunctionalTest.php

-
message: "#^Method TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\FunctionalTest\\:\\:logIn\\(\\) has no return typehint specified\\.$#"
count: 1
path: Tests/FunctionalTest.php

-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 15
path: Tests/FunctionalTest.php

-
message: "#^Parameter \\#3 \\$message of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: Tests/FunctionalTest.php

-
message: "#^Anonymous function should have native return typehint \"void\"\\.$#"
count: 1
path: Tests/GraphqliteTestingKernel.php

-
message: "#^Method TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\GraphqliteTestingKernel\\:\\:configureContainer\\(\\) has no return typehint specified\\.$#"
count: 1
path: Tests/GraphqliteTestingKernel.php

-
message: "#^Method TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\GraphqliteTestingKernel\\:\\:configureRoutes\\(\\) has no return typehint specified\\.$#"
count: 1
path: Tests/GraphqliteTestingKernel.php

-
message: "#^Method TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\GraphqliteTestingKernel\\:\\:configureRoutes\\(\\) has parameter \\$routes with no typehint specified\\.$#"
count: 1
path: Tests/GraphqliteTestingKernel.php

-
message: "#^Property TheCodingMachine\\\\Graphqlite\\\\Bundle\\\\Tests\\\\GraphqliteTestingKernel\\:\\:\\$enableLogin \\(string\\) does not accept string\\|null\\.$#"
count: 1
path: Tests/GraphqliteTestingKernel.php

-
message: "#^Cannot call method assertValid\\(\\) on object\\|null\\.$#"
count: 1
path: Tests/NoSecurityBundleTest.php

-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
path: Tests/NoSecurityBundleTest.php

25 changes: 23 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
- phpstan.baseline.neon
parameters:
tmpDir: .phpstan-cache
paths:
- .
excludePaths:
- vendor
- cache
- .phpstan-cache
level: max
polluteScopeWithLoopInitialAssignments: false
polluteScopeWithAlwaysIterableForeach: false
checkAlwaysTrueCheckTypeFunctionCall: true
checkAlwaysTrueInstanceof: true
checkAlwaysTrueStrictComparison: true
checkExplicitMixedMissingReturn: true
checkFunctionNameCase: true
checkInternalClassCaseSensitivity: true
checkMissingClosureNativeReturnTypehintRule: true
checkTooWideReturnTypesInProtectedAndPublicMethods: true
treatPhpDocTypesAsCertain: false
ignoreErrors:
- "#Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition::children\\(\\)#"
#includes:
# - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon

0 comments on commit 498296d

Please sign in to comment.