-
-
Notifications
You must be signed in to change notification settings - Fork 438
/
phpstan.neon
111 lines (94 loc) · 7.29 KB
/
phpstan.neon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
parameters:
level: 8 # TODO level up to max
stubFiles:
- _ide_helper.php
paths:
- benchmarks
- src
- tests
# Does not work with rector, comment in to diagnose potential issues with Octane
#checkOctaneCompatibility: true
reportUnmatchedIgnoredErrors: false # As long as we support multiple Laravel versions at once, there will be some dead spots
# Install https://plugins.jetbrains.com/plugin/7677-awesome-console to make those links clickable
editorUrl: '%%relFile%%:%%line%%'
editorUrlTitle: '%%relFile%%:%%line%%'
tmpDir: phpstan-tmp-dir
excludePaths:
- tests/Utils/Models/WithoutRelationClassImport.php # Intentionally wrong
- tests/LaravelPhpdocAlignmentFixer.php # Copied from laravel/pint
# laravel/pennant requires Laravel 10
- src/Pennant
- tests/Integration/Pennant
- src/Tracing/FederatedTracing/Proto # Generated classes from protobuf
# Ignore errors caused by the absence of Lumen in the dev dependencies
- tests/Unit/Testing/TestingTraitDummyLumen.php
# Native enums
- tests/Utils/Enums/ImageableType.php
- tests/Utils/Enums/ImageableType.php
ignoreErrors:
# PHPStan does not get it
- '#Parameter \#1 \$callback of static method Closure::fromCallable\(\) expects callable\(\): mixed, array{object, .*} given\.#'
# Some parts of Laravel are just really magical
- '#Parameter \#1 \$response of static method Nuwave\\Lighthouse\\Testing\\TestResponseUtils::extractValidationErrors\(\) expects Illuminate\\Testing\\TestResponse<Symfony\\Component\\HttpFoundation\\Response>, \$this\(Nuwave\\Lighthouse\\Testing\\TestResponseMixin\) given\.#'
- path: tests/database/factories
message: '#Variable \$factory might not be defined#'
# Mixins are magical
- path: src/Testing/TestResponseMixin.php
message: '#Method Nuwave\\Lighthouse\\Testing\\TestResponseMixin::assertGraphQLErrorMessage\(\) invoked with 1 parameter, 0 required\.#'
- path: src/Testing/TestResponseMixin.php
message: '#Method Nuwave\\Lighthouse\\Testing\\TestResponseMixin::assertGraphQLDebugMessage\(\) invoked with 1 parameter, 0 required\.#'
- path: src/Testing/TestResponseMixin.php
message: '#Anonymous function should return Illuminate\\Testing\\TestResponse but returns .*#'
# Relation forwards calls to Builder
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Builder<Illuminate\\Database\\Eloquent\\Model>|Illuminate\\Database\\Eloquent\\Relations\\Relation<Illuminate\\Database\\Eloquent\\Model>|Illuminate\\Database\\Query\\Builder::(orderBy|where|whereIn|whereNotIn|whereBetween|whereJsonContains|whereNotBetween)\(\)\.#'
# Laravel 11 changes a lot of generics
- '#generic class (Illuminate\\Database\\Eloquent\\Builder|Laravel\\Scout\\Builder)( but)? does not specify its types#'
- '#contains generic type Illuminate\\Testing\\TestResponse<.+> but class Illuminate\\Testing\\TestResponse is not generic\.#'
- '#Generic type Illuminate\\Database\\Eloquent\\Relations\\(HasOne|HasMany|BelongsToMany|MorphOne|MorphMany|MorphToMany)<.+, .+> in PHPDoc tag @return specifies 2 template types, but class Illuminate\\Database\\Eloquent\\Relations\\\1 supports only 1: TRelatedModel#'
- '#Method .+ should return Illuminate\\Database\\Eloquent\\Relations\\(HasOne|HasMany|BelongsToMany|MorphOne|MorphMany|MorphToMany)<(.+), .+> but returns Illuminate\\Database\\Eloquent\\Relations\\\1<\2>.#'
- '#Method .+ should return Illuminate\\Database\\Eloquent\\Relations\\(BelongsTo|MorphTo)<(.+), \$this\((.+)\)> but returns Illuminate\\Database\\Eloquent\\Relations\\\1<\2, \3>.#'
- '#Generic type Illuminate\\Database\\Eloquent\\Relations\\(HasOneThrough|HasManyThrough)<.+, .+, .+> in PHPDoc tag @return specifies 3 template types, but class Illuminate\\Database\\Eloquent\\Relations\\\1 supports only 1: TRelatedModel#'
- '#Method .+ should return Illuminate\\Database\\Eloquent\\Relations\\(HasOneThrough|HasManyThrough)<(.+), .+> but returns Illuminate\\Database\\Eloquent\\Relations\\\1<\2>.#'
# This test cheats and uses reflection to make assertions
- path: tests/Unit/Schema/Directives/BaseDirectiveTest.php
message: '#Call to protected method getModelClass\(\) of class Nuwave\\Lighthouse\\Schema\\Directives\\BaseDirective\.#'
# This is a library, so it should be extendable
- '#Unsafe usage of new static.*#'
# Ease transition for non-nullable properties towards native types https://github.com/phpstan/phpstan/issues/5150
- '#Property .* in isset\(\) is not nullable\.#'
# Unavailable in thecodingmachine/safe:1
- '#Function (hrtime) is unsafe to use\. It can return FALSE instead of throwing an exception\.#'
# Unavailable in thecodingmachine/safe:2
- '#Function (sort|substr|ksort) is unsafe to use\. It can return FALSE instead of throwing an exception\.#'
# Lumen type hints are just wrong
- '#Parameter \#1 \$content of function response expects string, .* given\.#'
# Seems like a bug in PHPStan
- '#Parameter \#2 \$type of method Nuwave\\Lighthouse\\Schema\\TypeRegistry::.+Lazy\(\) expects callable\(\): GraphQL\\Type\\Definition\\Type&GraphQL\\Type\\Definition\\NamedType, Closure\(\): GraphQL\\Type\\Definition\\ObjectType given\.#'
# Older versions of bensampo/laravel-enum are not generic yet
- '#contains generic type BenSampo\\Enum\\Enum<.+> but class BenSampo\\Enum\\Enum is not generic\.#'
# Ignore errors caused by the absence of Lumen in the dev dependencies
- path: src/Support/AppVersion.php
message: '#PHPDoc tag @var for variable \$container contains unknown class Laravel\\Lumen\\Application.#'
- path: src/Support/AppVersion.php
message: '#Call to method version\(\) on an unknown class Laravel\\Lumen\\Application.#'
- path: src/Subscriptions/SubscriptionRouter.php
messages:
- '#Parameter \$router of method Nuwave\\Lighthouse\\Subscriptions\\SubscriptionRouter::.+\(\) has invalid type Laravel\\Lumen\\Routing\\Router\.#'
- '#Call to method post\(\) on an unknown class Laravel\\Lumen\\Routing\\Router\.#'
- path: src/Http/routes.php
messages:
- '#PHPDoc tag @var for variable \$router contains unknown class Laravel\\Lumen\\Routing\\Router\.#'
- '#Call to method addRoute\(\) on an unknown class Laravel\\Lumen\\Routing\\Router\.#'
# Recent Mockery versions do not account for the last arg possibly being a closure
- path: tests/Unit/Subscriptions/Iterators/AuthenticatingSyncIteratorTest.php
message: '#Parameter \#2 \.\.\.\$args of static method Mockery::mock\(\) expects array\|class-string<Nuwave\\Lighthouse\\Subscriptions\\SubscriptionGuard>\|Nuwave\\Lighthouse\\Subscriptions\\SubscriptionGuard, Closure given\.#'
- path: tests/Integration/Schema/Directives/BuilderDirectiveTest.php
message: '#Return type of call to static method Mockery::mock\(\) contains unresolvable type\.#'
# Laravel added generics to Arr::first in 11.x, not sure how to handle them for now.
- path: src/OrderBy/OrderByDirective.php
message: '#Unable to resolve the template type TValue in call to method static method Illuminate\\Support\\Arr::first\(\)#'
- path: src/Testing/TestResponseMixin.php
message: '#Unable to resolve the template type TValue in call to method static method Illuminate\\Support\\Arr::first\(\)#'
# Lots of work to specify the generics, little gain
- path: tests
message: '#Method .+ return type with generic class Illuminate\\Testing\\TestResponse does not specify its types: TResponse#'