Skip to content

Commit baf73e3

Browse files
authored
Introduce phpstan-deprecation-rules
1 parent a61a04a commit baf73e3

File tree

5 files changed

+231
-5
lines changed

5 files changed

+231
-5
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"gedmo/doctrine-extensions": "^3.8",
3232
"nesbot/carbon": "^2.49",
3333
"php-parallel-lint/php-parallel-lint": "^1.2",
34+
"phpstan/phpstan-deprecation-rules": "^2.0",
3435
"phpstan/phpstan-phpunit": "^2.0",
3536
"phpstan/phpstan-strict-rules": "^2.0",
3637
"phpunit/phpunit": "^9.6.20",

phpstan-baseline-deprecations.neon

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '''
5+
#^Fetching class constant class of deprecated class Doctrine\\DBAL\\Types\\ArrayType\:
6+
Use \{@link JsonType\} instead\.$#
7+
'''
8+
identifier: classConstant.deprecatedClass
9+
count: 1
10+
path: src/Type/Doctrine/Descriptors/ArrayType.php
11+
12+
-
13+
message: '''
14+
#^Fetching class constant class of deprecated class Doctrine\\DBAL\\Types\\ObjectType\:
15+
Use \{@link JsonType\} instead\.$#
16+
'''
17+
identifier: classConstant.deprecatedClass
18+
count: 1
19+
path: src/Type/Doctrine/Descriptors/ObjectType.php
20+
21+
-
22+
message: '''
23+
#^Call to deprecated method getSchemaManager\(\) of class Doctrine\\DBAL\\Connection\:
24+
Use \{@see createSchemaManager\(\)\} instead\.$#
25+
'''
26+
identifier: method.deprecated
27+
count: 1
28+
path: tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php
29+
30+
-
31+
message: '''
32+
#^Fetching class constant class of deprecated class Doctrine\\DBAL\\Types\\ArrayType\:
33+
Use \{@link JsonType\} instead\.$#
34+
'''
35+
identifier: classConstant.deprecatedClass
36+
count: 1
37+
path: tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php
38+
39+
-
40+
message: '''
41+
#^Call to deprecated method create\(\) of class Doctrine\\ORM\\EntityManager\:
42+
Use \{@see DriverManager\:\:getConnection\(\)\} to bootstrap the connection and call the constructor\.$#
43+
'''
44+
identifier: staticMethod.deprecated
45+
count: 1
46+
path: src/Doctrine/Mapping/ClassMetadataFactory.php
47+
48+
-
49+
message: '''
50+
#^Fetching class constant class of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
51+
This class will be removed in 3\.0 without replacement\.$#
52+
'''
53+
identifier: classConstant.deprecatedClass
54+
count: 1
55+
path: src/Doctrine/Mapping/ClassMetadataFactory.php
56+
57+
-
58+
message: '''
59+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
60+
This class will be removed in 3\.0 without replacement\.$#
61+
'''
62+
identifier: new.deprecated
63+
count: 1
64+
path: src/Doctrine/Mapping/ClassMetadataFactory.php
65+
66+
-
67+
message: '''
68+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
69+
This class will be removed in 3\.0 without replacement\.$#
70+
'''
71+
identifier: new.deprecated
72+
count: 1
73+
path: tests/Classes/entity-manager.php
74+
75+
-
76+
message: '''
77+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
78+
This class will be removed in 3\.0 without replacement\.$#
79+
'''
80+
identifier: new.deprecated
81+
count: 1
82+
path: tests/DoctrineIntegration/ORM/entity-manager.php
83+
84+
-
85+
message: '''
86+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
87+
This class will be removed in 3\.0 without replacement\.$#
88+
'''
89+
identifier: new.deprecated
90+
count: 1
91+
path: tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php
92+
93+
-
94+
message: '''
95+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
96+
This class will be removed in 3\.0 without replacement\.$#
97+
'''
98+
identifier: new.deprecated
99+
count: 1
100+
path: tests/Rules/DeadCode/entity-manager.php
101+
102+
-
103+
message: '''
104+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
105+
This class will be removed in 3\.0 without replacement\.$#
106+
'''
107+
identifier: new.deprecated
108+
count: 1
109+
path: tests/Rules/Properties/entity-manager.php
110+
111+
-
112+
message: '''
113+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
114+
This class will be removed in 3\.0 without replacement\.$#
115+
'''
116+
identifier: new.deprecated
117+
count: 1
118+
path: tests/Type/Doctrine/DBAL/mysqli.php
119+
120+
-
121+
message: '''
122+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
123+
This class will be removed in 3\.0 without replacement\.$#
124+
'''
125+
identifier: new.deprecated
126+
count: 1
127+
path: tests/Type/Doctrine/DBAL/pdo.php

phpstan-baseline-orm-3.neon

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,102 @@ parameters:
5454
message: "#^Parameter \\#2 \\$className of static method Doctrine\\\\DBAL\\\\Types\\\\Type\\:\\:addType\\(\\) expects class\\-string\\<Doctrine\\\\DBAL\\\\Types\\\\Type\\>, string given\\.$#"
5555
count: 1
5656
path: tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php
57+
58+
-
59+
message: '''
60+
#^Fetching class constant class of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
61+
This class will be removed in 3\.0 without replacement\.
62+
Copyright \(c\) Doctrine Project
63+
From https\://github\.com/doctrine/orm/blob/40fbbf4429b0d66517244051237a2bd0616a7a13/src/Mapping/Driver/AnnotationDriver\.php$#
64+
'''
65+
identifier: classConstant.deprecatedClass
66+
count: 1
67+
path: src/Doctrine/Mapping/ClassMetadataFactory.php
68+
69+
-
70+
message: '''
71+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
72+
This class will be removed in 3\.0 without replacement\.
73+
Copyright \(c\) Doctrine Project
74+
From https\://github\.com/doctrine/orm/blob/40fbbf4429b0d66517244051237a2bd0616a7a13/src/Mapping/Driver/AnnotationDriver\.php$#
75+
'''
76+
identifier: new.deprecated
77+
count: 1
78+
path: src/Doctrine/Mapping/ClassMetadataFactory.php
79+
80+
-
81+
message: '''
82+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
83+
This class will be removed in 3\.0 without replacement\.
84+
Copyright \(c\) Doctrine Project
85+
From https\://github\.com/doctrine/orm/blob/40fbbf4429b0d66517244051237a2bd0616a7a13/src/Mapping/Driver/AnnotationDriver\.php$#
86+
'''
87+
identifier: new.deprecated
88+
count: 1
89+
path: tests/Classes/entity-manager.php
90+
91+
-
92+
message: '''
93+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
94+
This class will be removed in 3\.0 without replacement\.
95+
Copyright \(c\) Doctrine Project
96+
From https\://github\.com/doctrine/orm/blob/40fbbf4429b0d66517244051237a2bd0616a7a13/src/Mapping/Driver/AnnotationDriver\.php$#
97+
'''
98+
identifier: new.deprecated
99+
count: 1
100+
path: tests/DoctrineIntegration/ORM/entity-manager.php
101+
102+
-
103+
message: '''
104+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
105+
This class will be removed in 3\.0 without replacement\.
106+
Copyright \(c\) Doctrine Project
107+
From https\://github\.com/doctrine/orm/blob/40fbbf4429b0d66517244051237a2bd0616a7a13/src/Mapping/Driver/AnnotationDriver\.php$#
108+
'''
109+
identifier: new.deprecated
110+
count: 1
111+
path: tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php
112+
113+
-
114+
message: '''
115+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
116+
This class will be removed in 3\.0 without replacement\.
117+
Copyright \(c\) Doctrine Project
118+
From https\://github\.com/doctrine/orm/blob/40fbbf4429b0d66517244051237a2bd0616a7a13/src/Mapping/Driver/AnnotationDriver\.php$#
119+
'''
120+
identifier: new.deprecated
121+
count: 1
122+
path: tests/Rules/DeadCode/entity-manager.php
123+
124+
-
125+
message: '''
126+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
127+
This class will be removed in 3\.0 without replacement\.
128+
Copyright \(c\) Doctrine Project
129+
From https\://github\.com/doctrine/orm/blob/40fbbf4429b0d66517244051237a2bd0616a7a13/src/Mapping/Driver/AnnotationDriver\.php$#
130+
'''
131+
identifier: new.deprecated
132+
count: 1
133+
path: tests/Rules/Properties/entity-manager.php
134+
135+
-
136+
message: '''
137+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
138+
This class will be removed in 3\.0 without replacement\.
139+
Copyright \(c\) Doctrine Project
140+
From https\://github\.com/doctrine/orm/blob/40fbbf4429b0d66517244051237a2bd0616a7a13/src/Mapping/Driver/AnnotationDriver\.php$#
141+
'''
142+
identifier: new.deprecated
143+
count: 1
144+
path: tests/Type/Doctrine/DBAL/mysqli.php
145+
146+
-
147+
message: '''
148+
#^Instantiation of deprecated class Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver\:
149+
This class will be removed in 3\.0 without replacement\.
150+
Copyright \(c\) Doctrine Project
151+
From https\://github\.com/doctrine/orm/blob/40fbbf4429b0d66517244051237a2bd0616a7a13/src/Mapping/Driver/AnnotationDriver\.php$#
152+
'''
153+
identifier: new.deprecated
154+
count: 1
155+
path: tests/Type/Doctrine/DBAL/pdo.php

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ includes:
22
- extension.neon
33
- rules.neon
44
- phpstan-baseline.neon
5+
- phpstan-baseline-deprecations.neon
56
- phpstan-baseline-dbal-3.neon
67
- compatibility/orm-3-baseline.php
78
- vendor/phpstan/phpstan-strict-rules/rules.neon
9+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
810
- vendor/phpstan/phpstan-phpunit/extension.neon
911
- vendor/phpstan/phpstan-phpunit/rules.neon
1012
- phar://phpstan.phar/conf/bleedingEdge.neon

src/Type/Doctrine/Collection/IsEmptyTypeSpecifyingExtension.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ public function isMethodSupported(
4343
TypeSpecifierContext $context
4444
): bool
4545
{
46-
return (
47-
$methodReflection->getDeclaringClass()->getName() === $this->collectionClass
48-
|| $methodReflection->getDeclaringClass()->isSubclassOf($this->collectionClass)
49-
)
50-
&& $methodReflection->getName() === self::IS_EMPTY_METHOD_NAME;
46+
return $methodReflection->getDeclaringClass()->is($this->collectionClass)
47+
&& $methodReflection->getName() === self::IS_EMPTY_METHOD_NAME;
5148
}
5249

5350
public function specifyTypes(

0 commit comments

Comments
 (0)