Skip to content

Commit f531bae

Browse files
authored
Merge pull request doctrine#443 from greg0ire/phpstan-2
Upgrade to PHPStan 2.1.30
2 parents 4fec5bf + 8e38687 commit f531bae

File tree

3 files changed

+62
-25
lines changed

3 files changed

+62
-25
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
"psr/cache": "^1.0 || ^2.0 || ^3.0"
2626
},
2727
"require-dev": {
28-
"phpstan/phpstan": "1.12.7",
29-
"phpstan/phpstan-phpunit": "^1",
30-
"phpstan/phpstan-strict-rules": "^1.1",
28+
"phpstan/phpstan": "^1 || 2.1.30",
29+
"phpstan/phpstan-phpunit": "^1 || ^2",
30+
"phpstan/phpstan-strict-rules": "^1 || ^2",
3131
"doctrine/coding-standard": "^12 || ^14",
3232
"doctrine/common": "^3.0",
3333
"phpunit/phpunit": "^8.5.38 || ^9.5",

phpstan-baseline.neon

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,139 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Call to an undefined static method T of object\\:\\:loadMetadata\\(\\)\\.$#"
4+
message: '#^Call to an undefined static method T of object\:\:loadMetadata\(\)\.$#'
5+
identifier: staticMethod.notFound
56
count: 1
67
path: src/Persistence/Mapping/Driver/StaticPHPDriver.php
78

89
-
9-
message: "#^Call to function method_exists\\(\\) with TObjectManager of Doctrine\\\\Persistence\\\\ObjectManager and 'isUninitializedObje…' will always evaluate to true\\.$#"
10+
message: '#^Call to function method_exists\(\) with TObjectManager of Doctrine\\Persistence\\ObjectManager and ''isUninitializedObje…'' will always evaluate to true\.$#'
11+
identifier: function.alreadyNarrowedType
1012
count: 1
1113
path: src/Persistence/ObjectManagerDecorator.php
1214

1315
-
14-
message: "#^Doctrine\\\\Persistence\\\\Reflection\\\\EnumReflectionProperty\\:\\:__construct\\(\\) does not call parent constructor from ReflectionProperty\\.$#"
16+
message: '#^Template type TObjectManager is declared as covariant, but occurs in invariant position in property Doctrine\\Persistence\\ObjectManagerDecorator\:\:\$wrapped\.$#'
17+
identifier: generics.variance
18+
count: 1
19+
path: src/Persistence/ObjectManagerDecorator.php
20+
21+
-
22+
message: '#^Doctrine\\Persistence\\Reflection\\EnumReflectionProperty\:\:__construct\(\) does not call parent constructor from ReflectionProperty\.$#'
23+
identifier: constructor.missingParentCall
1524
count: 1
1625
path: src/Persistence/Reflection/EnumReflectionProperty.php
1726

1827
-
19-
message: "#^Method Doctrine\\\\Persistence\\\\Reflection\\\\EnumReflectionProperty\\:\\:getDeclaringClass\\(\\) return type with generic class ReflectionClass does not specify its types\\: T$#"
28+
message: '#^Method Doctrine\\Persistence\\Reflection\\EnumReflectionProperty\:\:getDeclaringClass\(\) return type with generic class ReflectionClass does not specify its types\: T$#'
29+
identifier: missingType.generics
2030
count: 1
2131
path: src/Persistence/Reflection/EnumReflectionProperty.php
2232

2333
-
24-
message: "#^Method Doctrine\\\\Persistence\\\\Reflection\\\\EnumReflectionProperty\\:\\:toEnum\\(\\) should return array\\<BackedEnum\\>\\|BackedEnum but returns array\\<BackedEnum\\|int\\|string\\>\\.$#"
34+
message: '#^Method Doctrine\\Persistence\\Reflection\\EnumReflectionProperty\:\:toEnum\(\) should return array\<BackedEnum\>\|BackedEnum but returns array\<BackedEnum\|int\|string\>\.$#'
35+
identifier: return.type
2536
count: 1
2637
path: src/Persistence/Reflection/EnumReflectionProperty.php
2738

2839
-
29-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(BackedEnum\\|int\\|string\\)\\: mixed\\)\\|null, array\\{class\\-string\\<BackedEnum\\>, 'from'\\} given\\.$#"
40+
message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(BackedEnum\|int\|string\)\: mixed\)\|null, array\{class\-string\<BackedEnum\>, ''from''\} given\.$#'
41+
identifier: argument.type
3042
count: 1
3143
path: src/Persistence/Reflection/EnumReflectionProperty.php
3244

3345
-
34-
message: "#^Variable property access on \\$this\\(Doctrine\\\\Persistence\\\\Reflection\\\\TypedNoDefaultRuntimePublicReflectionProperty\\)\\.$#"
46+
message: '#^Variable property access on \$this\(Doctrine\\Persistence\\Reflection\\TypedNoDefaultRuntimePublicReflectionProperty\)\.$#'
47+
identifier: property.dynamicName
3548
count: 1
3649
path: src/Persistence/Reflection/TypedNoDefaultRuntimePublicReflectionProperty.php
3750

3851
-
39-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{'Doctrine\\\\\\\\Tests…', 'Doctrine\\\\\\\\Tests\\\\\\\\ORM…', 'Doctrine\\\\\\\\Tests\\\\\\\\ORM…'\\} and array\\<int, class\\-string\\> will always evaluate to false\\.$#"
52+
message: '#^PHPDoc tag @var with type Doctrine\\Persistence\\Mapping\\ClassMetadata\<object\> is not subtype of native type PHPUnit\\Framework\\MockObject\\MockObject\.$#'
53+
identifier: varTag.nativeType
54+
count: 1
55+
path: tests/Persistence/Mapping/ClassMetadataFactoryTest.php
56+
57+
-
58+
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertSame\(\) with array\{''Doctrine\\\\Tests…'', ''Doctrine\\\\Tests\\\\ORM…'', ''Doctrine\\\\Tests\\\\ORM…''\} and list\<class\-string\> will always evaluate to false\.$#'
59+
identifier: staticMethod.impossibleType
4060
count: 1
4161
path: tests/Persistence/Mapping/DriverChainTest.php
4262

4363
-
44-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{'Doctrine\\\\\\\\Tests…', 'Other\\\\\\\\Class'\\} and array\\<int, class\\-string\\> will always evaluate to false\\.$#"
64+
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertSame\(\) with array\{''Doctrine\\\\Tests…'', ''Other\\\\Class''\} and list\<class\-string\> will always evaluate to false\.$#'
65+
identifier: staticMethod.impossibleType
4566
count: 1
4667
path: tests/Persistence/Mapping/DriverChainTest.php
4768

4869
-
49-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{'Foo\\\\\\\\stdClass', 'Foo\\\\\\\\sub\\\\\\\\subClass', 'Foo\\\\\\\\sub\\\\\\\\subsub…'\\} and array\\<int, class\\-string\\> will always evaluate to false\\.$#"
70+
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertSame\(\) with array\{''Foo\\\\stdClass'', ''Foo\\\\sub\\\\subClass'', ''Foo\\\\sub\\\\subsub…''\} and list\<class\-string\> will always evaluate to false\.$#'
71+
identifier: staticMethod.impossibleType
5072
count: 1
5173
path: tests/Persistence/Mapping/SymfonyFileLocatorTest.php
5274

5375
-
54-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with non\\-empty\\-array\\<int, 'Foo\\\\\\\\Bar\\\\\\\\subDirClass'\\|'Foo\\\\\\\\global'\\|'Foo\\\\\\\\stdClass'\\> and array\\<int, class\\-string\\> will always evaluate to false\\.$#"
76+
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertSame\(\) with non\-empty\-list\<''Foo\\\\Bar\\\\subDirClass''\|''Foo\\\\global''\|''Foo\\\\stdClass''\> and list\<class\-string\> will always evaluate to false\.$#'
77+
identifier: staticMethod.impossibleType
5578
count: 1
5679
path: tests/Persistence/Mapping/SymfonyFileLocatorTest.php
5780

5881
-
59-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with non\\-empty\\-array\\<int, 'Foo\\\\\\\\Bar\\\\\\\\subDirClass'\\|'Foo\\\\\\\\stdClass'\\> and array\\<int, class\\-string\\> will always evaluate to false\\.$#"
82+
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertSame\(\) with non\-empty\-list\<''Foo\\\\Bar\\\\subDirClass''\|''Foo\\\\stdClass''\> and list\<class\-string\> will always evaluate to false\.$#'
83+
identifier: staticMethod.impossibleType
6084
count: 1
6185
path: tests/Persistence/Mapping/SymfonyFileLocatorTest.php
6286

6387
-
64-
message: "#^Property Doctrine\\\\Tests\\\\Persistence\\\\RuntimePublicReflectionPropertyTestProxyMock\\:\\:\\$checkedProperty \\(string\\) in isset\\(\\) is not nullable\\.$#"
88+
message: '#^Property Doctrine\\Tests\\Persistence\\RuntimePublicReflectionPropertyTestProxyMock\:\:\$checkedProperty \(string\) in isset\(\) is not nullable\.$#'
89+
identifier: isset.property
6590
count: 1
6691
path: tests/Persistence/RuntimePublicReflectionPropertyTest.php
6792

6893
-
69-
message: "#^Method Doctrine\\\\Tests\\\\Persistence\\\\RuntimeReflectionPropertyTestProxyMock\\:\\:__setInitialized\\(\\) has parameter \\$initialized with no type specified\\.$#"
94+
message: '#^Method Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock\:\:__setInitialized\(\) has parameter \$initialized with no type specified\.$#'
95+
identifier: missingType.parameter
96+
count: 1
97+
path: tests/Persistence/RuntimeReflectionPropertyTest.php
98+
99+
-
100+
message: '#^Property Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestClass\:\:\$privateTest \(string\|null\) is never assigned null so it can be removed from the property type\.$#'
101+
identifier: property.unusedType
70102
count: 1
71103
path: tests/Persistence/RuntimeReflectionPropertyTest.php
72104

73105
-
74-
message: "#^Property Doctrine\\\\Tests\\\\Persistence\\\\RuntimeReflectionPropertyTestProxyMock\\:\\:\\$checkedProperty \\(string\\) in isset\\(\\) is not nullable\\.$#"
106+
message: '#^Property Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock\:\:\$checkedProperty \(string\) in isset\(\) is not nullable\.$#'
107+
identifier: isset.property
75108
count: 1
76109
path: tests/Persistence/RuntimeReflectionPropertyTest.php
77110

78111
-
79-
message: "#^Property Doctrine\\\\Tests_PHP74\\\\Persistence\\\\Mapping\\\\RuntimeReflectionServiceTest\\:\\:\\$nonTypedDefaultProperty is never read, only written\\.$#"
112+
message: '#^Property Doctrine\\Tests_PHP74\\Persistence\\Mapping\\RuntimeReflectionServiceTest\:\:\$nonTypedDefaultProperty is never read, only written\.$#'
113+
identifier: property.onlyWritten
80114
count: 1
81115
path: tests_php74/Persistence/Mapping/RuntimeReflectionServiceTest.php
82116

83117
-
84-
message: "#^Property Doctrine\\\\Tests_PHP74\\\\Persistence\\\\Mapping\\\\RuntimeReflectionServiceTest\\:\\:\\$nonTypedNoDefaultProperty is unused\\.$#"
118+
message: '#^Property Doctrine\\Tests_PHP74\\Persistence\\Mapping\\RuntimeReflectionServiceTest\:\:\$nonTypedNoDefaultProperty is unused\.$#'
119+
identifier: property.unused
85120
count: 1
86121
path: tests_php74/Persistence/Mapping/RuntimeReflectionServiceTest.php
87122

88123
-
89-
message: "#^Property Doctrine\\\\Tests_PHP74\\\\Persistence\\\\Mapping\\\\RuntimeReflectionServiceTest\\:\\:\\$typedDefaultProperty is never read, only written\\.$#"
124+
message: '#^Property Doctrine\\Tests_PHP74\\Persistence\\Mapping\\RuntimeReflectionServiceTest\:\:\$typedDefaultProperty is never read, only written\.$#'
125+
identifier: property.onlyWritten
90126
count: 1
91127
path: tests_php74/Persistence/Mapping/RuntimeReflectionServiceTest.php
92128

93129
-
94-
message: "#^Property Doctrine\\\\Tests_PHP74\\\\Persistence\\\\Mapping\\\\RuntimeReflectionServiceTest\\:\\:\\$typedNoDefaultProperty is unused\\.$#"
130+
message: '#^Property Doctrine\\Tests_PHP74\\Persistence\\Mapping\\RuntimeReflectionServiceTest\:\:\$typedNoDefaultProperty is unused\.$#'
131+
identifier: property.unused
95132
count: 1
96133
path: tests_php74/Persistence/Mapping/RuntimeReflectionServiceTest.php
97134

98135
-
99-
message: "#^Property Doctrine\\\\Tests_PHP74\\\\Persistence\\\\Reflection\\\\TypedFoo\\:\\:\\$id is never read, only written\\.$#"
136+
message: '#^Property Doctrine\\Tests_PHP74\\Persistence\\Reflection\\TypedFoo\:\:\$id is never read, only written\.$#'
137+
identifier: property.onlyWritten
100138
count: 1
101139
path: tests_php74/Persistence/Reflection/TypedNoDefaultReflectionPropertyTest.php

src/Persistence/Mapping/Driver/FileDriver.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Doctrine\Persistence\Mapping\Driver;
66

7-
use Doctrine\Persistence\Mapping\ClassMetadata;
87
use Doctrine\Persistence\Mapping\MappingException;
98

109
use function array_keys;
@@ -137,7 +136,7 @@ public function getAllClassNames()
137136
return $this->locator->getAllClassNames($this->globalBasename);
138137
}
139138

140-
/** @phpstan-var array<class-string, ClassMetadata<object>> $classCache */
139+
/** @phpstan-var non-empty-array<class-string, T> $classCache */
141140
$classCache = $this->classCache;
142141

143142
/** @var list<class-string> $keys */

0 commit comments

Comments
 (0)