Skip to content

Commit 397358c

Browse files
authored
Merge pull request #12133 from greg0ire/update-phpstan
PHPStan 2.1.22
2 parents ac37a87 + ae5e9c8 commit 397358c

22 files changed

+99
-108
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"doctrine/coding-standard": "^9.0.2 || ^13.0",
4545
"phpbench/phpbench": "^0.16.10 || ^1.0",
4646
"phpstan/extension-installer": "~1.1.0 || ^1.4",
47-
"phpstan/phpstan": "~1.4.10 || 2.0.3",
47+
"phpstan/phpstan": "~1.4.10 || 2.1.22",
4848
"phpstan/phpstan-deprecation-rules": "^1 || ^2",
4949
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.6",
5050
"psr/log": "^1 || ^2 || ^3",

phpstan-baseline.neon

Lines changed: 40 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ parameters:
1818
count: 1
1919
path: src/AbstractQuery.php
2020

21-
-
22-
message: '#^Expression "\$setCacheEntry\(\$data\)" on a separate line does not do anything\.$#'
23-
identifier: expr.resultUnused
24-
count: 1
25-
path: src/AbstractQuery.php
26-
27-
-
28-
message: '#^Expression "\$setCacheEntry\(\$stmt\)" on a separate line does not do anything\.$#'
29-
identifier: expr.resultUnused
30-
count: 1
31-
path: src/AbstractQuery.php
32-
3321
-
3422
message: '#^Method Doctrine\\ORM\\AbstractQuery\:\:getParameter\(\) should return Doctrine\\ORM\\Query\\Parameter\|null but returns Doctrine\\ORM\\Query\\Parameter\|false\|null\.$#'
3523
identifier: return.type
@@ -102,6 +90,12 @@ parameters:
10290
count: 1
10391
path: src/Cache/CollectionHydrator.php
10492

93+
-
94+
message: '#^If condition is always false\.$#'
95+
identifier: if.alwaysFalse
96+
count: 1
97+
path: src/Cache/DefaultCache.php
98+
10599
-
106100
message: '#^Method Doctrine\\ORM\\Cache\\DefaultCache\:\:buildCollectionCacheKey\(\) has parameter \$metadata with generic class Doctrine\\ORM\\Mapping\\ClassMetadata but does not specify its types\: T$#'
107101
identifier: missingType.generics
@@ -264,12 +258,6 @@ parameters:
264258
count: 1
265259
path: src/Cache/DefaultQueryCache.php
266260

267-
-
268-
message: '#^Parameter \#1 \$result of class Doctrine\\ORM\\Cache\\QueryCacheEntry constructor expects array\<string, mixed\>, array\<int\|string, array\<string, array\<mixed\>\>\> given\.$#'
269-
identifier: argument.type
270-
count: 1
271-
path: src/Cache/DefaultQueryCache.php
272-
273261
-
274262
message: '#^Parameter \#2 \$key of method Doctrine\\ORM\\Cache\\Logging\\CacheLogger\:\:entityCacheHit\(\) expects Doctrine\\ORM\\Cache\\EntityCacheKey, Doctrine\\ORM\\Cache\\CacheKey given\.$#'
275263
identifier: argument.type
@@ -630,6 +618,18 @@ parameters:
630618
count: 1
631619
path: src/Cache/TimestampQueryCacheValidator.php
632620

621+
-
622+
message: '#^Call to function is_a\(\) with arguments class\-string\<Doctrine\\ORM\\EntityRepository\>, ''Doctrine\\\\ORM\\\\EntityRepository'' and true will always evaluate to true\.$#'
623+
identifier: function.alreadyNarrowedType
624+
count: 1
625+
path: src/Configuration.php
626+
627+
-
628+
message: '#^Call to function is_a\(\) with arguments class\-string\<Doctrine\\ORM\\EntityRepository\>, ''Doctrine\\\\Persistence\\\\ObjectRepository'' and true will always evaluate to true\.$#'
629+
identifier: function.alreadyNarrowedType
630+
count: 1
631+
path: src/Configuration.php
632+
633633
-
634634
message: '#^Call to function method_exists\(\) with ''Doctrine\\\\DBAL\\\\Configuration'' and ''getResultCache'' will always evaluate to true\.$#'
635635
identifier: function.alreadyNarrowedType
@@ -973,13 +973,13 @@ parameters:
973973
path: src/Internal/Hydration/AbstractHydrator.php
974974

975975
-
976-
message: '#^Parameter &\$id by\-ref type of method Doctrine\\ORM\\Internal\\Hydration\\AbstractHydrator\:\:gatherRowData\(\) expects array\<string, string\>, array\<int\|string, string\> given\.$#'
976+
message: '#^Parameter &\$id by\-ref type of method Doctrine\\ORM\\Internal\\Hydration\\AbstractHydrator\:\:gatherRowData\(\) expects array\<string, string\>, array\<string\> given\.$#'
977977
identifier: parameterByRef.type
978978
count: 1
979979
path: src/Internal/Hydration/AbstractHydrator.php
980980

981981
-
982-
message: '#^Parameter &\$nonemptyComponents by\-ref type of method Doctrine\\ORM\\Internal\\Hydration\\AbstractHydrator\:\:gatherRowData\(\) expects array\<string, bool\>, array\<int\|string, bool\> given\.$#'
982+
message: '#^Parameter &\$nonemptyComponents by\-ref type of method Doctrine\\ORM\\Internal\\Hydration\\AbstractHydrator\:\:gatherRowData\(\) expects array\<string, bool\>, array\<bool\> given\.$#'
983983
identifier: parameterByRef.type
984984
count: 1
985985
path: src/Internal/Hydration/AbstractHydrator.php
@@ -1188,6 +1188,12 @@ parameters:
11881188
count: 5
11891189
path: src/Mapping/ClassMetadata.php
11901190

1191+
-
1192+
message: '#^Call to function is_a\(\) with Doctrine\\DBAL\\Platforms\\OraclePlatform and ''Doctrine\\\\DBAL…'' will always evaluate to false\.$#'
1193+
identifier: function.impossibleType
1194+
count: 1
1195+
path: src/Mapping/ClassMetadataFactory.php
1196+
11911197
-
11921198
message: '#^If condition is always true\.$#'
11931199
identifier: if.alwaysTrue
@@ -1669,7 +1675,7 @@ parameters:
16691675
path: src/Mapping/ClassMetadataInfo.php
16701676

16711677
-
1672-
message: '#^Property Doctrine\\ORM\\Mapping\\ClassMetadataInfo\<T of object\>\:\:\$embeddedClasses \(array\<string, array\{class\: class\-string, columnPrefix\: string\|null, declaredField\: string\|null, originalField\: string\|null, inherited\?\: class\-string, declared\?\: class\-string\}\>\) does not accept non\-empty\-array\<int\|string, array\{class\: string, columnPrefix\: mixed, declaredField\: mixed, originalField\: mixed, inherited\?\: class\-string, declared\?\: class\-string\}\>\.$#'
1678+
message: '#^Property Doctrine\\ORM\\Mapping\\ClassMetadataInfo\<T of object\>\:\:\$embeddedClasses \(array\<string, array\{class\: class\-string, columnPrefix\: string\|null, declaredField\: string\|null, originalField\: string\|null, inherited\?\: class\-string, declared\?\: class\-string\}\>\) does not accept non\-empty\-array\<array\{class\: string, columnPrefix\: mixed, declaredField\: mixed, originalField\: mixed, inherited\?\: class\-string, declared\?\: class\-string\}\>\.$#'
16731679
identifier: assign.propertyType
16741680
count: 1
16751681
path: src/Mapping/ClassMetadataInfo.php
@@ -1681,19 +1687,7 @@ parameters:
16811687
path: src/Mapping/ClassMetadataInfo.php
16821688

16831689
-
1684-
message: '#^Property Doctrine\\ORM\\Mapping\\ClassMetadataInfo\<T of object\>\:\:\$namedNativeQueries \(array\<string, array\<string, mixed\>\>\) does not accept array\<int\|string, array\<string, mixed\>\>\.$#'
1685-
identifier: assign.propertyType
1686-
count: 1
1687-
path: src/Mapping/ClassMetadataInfo.php
1688-
1689-
-
1690-
message: '#^Property Doctrine\\ORM\\Mapping\\ClassMetadataInfo\<T of object\>\:\:\$namedQueries \(array\<string, array\<string, mixed\>\>\) does not accept array\<int\|string, array\<string, mixed\>\>\.$#'
1691-
identifier: assign.propertyType
1692-
count: 1
1693-
path: src/Mapping/ClassMetadataInfo.php
1694-
1695-
-
1696-
message: '#^Property Doctrine\\ORM\\Mapping\\ClassMetadataInfo\<T of object\>\:\:\$sqlResultSetMappings \(array\<string, array\{name\: string, entities\: array\<mixed\>, columns\: array\<mixed\>\}\>\) does not accept non\-empty\-array\<int\|string, array\<string, mixed\>\>\.$#'
1690+
message: '#^Property Doctrine\\ORM\\Mapping\\ClassMetadataInfo\<T of object\>\:\:\$sqlResultSetMappings \(array\<string, array\{name\: string, entities\: array\<mixed\>, columns\: array\<mixed\>\}\>\) does not accept non\-empty\-array\<non\-empty\-array\<string, mixed\>\>\.$#'
16971691
identifier: assign.propertyType
16981692
count: 1
16991693
path: src/Mapping/ClassMetadataInfo.php
@@ -1722,6 +1716,12 @@ parameters:
17221716
count: 1
17231717
path: src/Mapping/ClassMetadataInfo.php
17241718

1719+
-
1720+
message: '#^Template type T is declared as covariant, but occurs in invariant position in return type of method Doctrine\\ORM\\Mapping\\ClassMetadataInfo\:\:getReflectionClass\(\)\.$#'
1721+
identifier: generics.variance
1722+
count: 1
1723+
path: src/Mapping/ClassMetadataInfo.php
1724+
17251725
-
17261726
message: '#^@readonly property cannot have a default value\.$#'
17271727
identifier: property.readOnlyByPhpDocDefaultValue
@@ -3195,33 +3195,6 @@ parameters:
31953195
count: 1
31963196
path: src/Proxy/ProxyFactory.php
31973197

3198-
-
3199-
message: '''
3200-
#^Call to method __construct\(\) of deprecated class Doctrine\\Common\\Proxy\\AbstractProxyFactory\:
3201-
The AbstractProxyFactory class is deprecated since doctrine/common 3\.5\.$#
3202-
'''
3203-
identifier: staticMethod.deprecatedClass
3204-
count: 1
3205-
path: src/Proxy/ProxyFactory.php
3206-
3207-
-
3208-
message: '''
3209-
#^Call to method generateProxyClasses\(\) of deprecated class Doctrine\\Common\\Proxy\\AbstractProxyFactory\:
3210-
The AbstractProxyFactory class is deprecated since doctrine/common 3\.5\.$#
3211-
'''
3212-
identifier: staticMethod.deprecatedClass
3213-
count: 1
3214-
path: src/Proxy/ProxyFactory.php
3215-
3216-
-
3217-
message: '''
3218-
#^Call to method getProxy\(\) of deprecated class Doctrine\\Common\\Proxy\\AbstractProxyFactory\:
3219-
The AbstractProxyFactory class is deprecated since doctrine/common 3\.5\.$#
3220-
'''
3221-
identifier: staticMethod.deprecatedClass
3222-
count: 1
3223-
path: src/Proxy/ProxyFactory.php
3224-
32253198
-
32263199
message: '''
32273200
#^Class Doctrine\\ORM\\Proxy\\ProxyFactory extends deprecated class Doctrine\\Common\\Proxy\\AbstractProxyFactory\:
@@ -3243,15 +3216,6 @@ parameters:
32433216
count: 1
32443217
path: src/Proxy/ProxyFactory.php
32453218

3246-
-
3247-
message: '''
3248-
#^Instantiation of deprecated class Doctrine\\Common\\Proxy\\ProxyGenerator\:
3249-
The ProxyGenerator class is deprecated since doctrine/common 3\.5\.$#
3250-
'''
3251-
identifier: new.deprecated
3252-
count: 1
3253-
path: src/Proxy/ProxyFactory.php
3254-
32553219
-
32563220
message: '#^Method Doctrine\\ORM\\Proxy\\ProxyFactory\:\:createCloner\(\) has Doctrine\\ORM\\EntityNotFoundException in PHPDoc @throws tag but it''s not thrown\.$#'
32573221
identifier: throws.unusedType
@@ -3987,12 +3951,6 @@ parameters:
39873951
count: 5
39883952
path: src/Query/SqlWalker.php
39893953

3990-
-
3991-
message: '#^Property Doctrine\\ORM\\Query\\SqlWalker\:\:\$selectedClasses \(array\<string, array\{class\: Doctrine\\ORM\\Mapping\\ClassMetadata, dqlAlias\: string, resultAlias\: string\|null\}\>\) does not accept non\-empty\-array\<int\|string, array\{class\: Doctrine\\ORM\\Mapping\\ClassMetadata, dqlAlias\: mixed, resultAlias\: string\|null\}\>\.$#'
3992-
identifier: assign.propertyType
3993-
count: 1
3994-
path: src/Query/SqlWalker.php
3995-
39963954
-
39973955
message: '#^Property Doctrine\\ORM\\Query\\SqlWalker\:\:\$selectedClasses with generic class Doctrine\\ORM\\Mapping\\ClassMetadata does not specify its types\: T$#'
39983956
identifier: missingType.generics
@@ -5067,6 +5025,12 @@ parameters:
50675025
count: 1
50685026
path: src/Tools/Pagination/LimitSubqueryOutputWalker.php
50695027

5028+
-
5029+
message: '#^Method Doctrine\\ORM\\Tools\\Pagination\\Paginator\:\:setUseOutputWalkers\(\) should return static\(Doctrine\\ORM\\Tools\\Pagination\\Paginator\<T\>\) but returns \$this\(Doctrine\\ORM\\Tools\\Pagination\\Paginator\<T\>\)\.$#'
5030+
identifier: return.type
5031+
count: 1
5032+
path: src/Tools/Pagination/Paginator.php
5033+
50705034
-
50715035
message: '#^PHPDoc tag @var for variable \$parameters contains generic interface Doctrine\\Common\\Collections\\Collection but does not specify its types\: TKey, T$#'
50725036
identifier: missingType.generics

phpstan-dbal2.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ parameters:
5757
count: 2
5858
path: src/Tools/SchemaTool.php
5959

60+
-
61+
message: '#introspectSchema#'
62+
count: 2
63+
identifier: 'method.notFound'
64+
path: src/Tools/SchemaTool.php
65+
66+
-
67+
message: '#getMaxIdentifierLength#'
68+
identifier: 'method.deprecatedClass'
69+
path: src/Mapping/ClassMetadataFactory.php
70+
6071
-
6172
message: "#^Parameter \\#2 \\$start of method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getSubstringExpression\\(\\) expects int, string given\\.$#"
6273
count: 1

phpstan-persistence2.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,13 @@ parameters:
100100
-
101101
message: '#^Parameter \#1 \$classNames of method Doctrine\\ORM\\Mapping\\ClassMetadataInfo\<object\>\:\:setParentClasses\(\) expects list\<class\-string\>, array\<string\> given\.$#'
102102
path: src/Mapping/ClassMetadataFactory.php
103+
104+
-
105+
message: '#loadMappingFile#'
106+
identifier: 'return.type'
107+
path: src/Mapping/Driver/XmlDriver.php
108+
109+
-
110+
message: '#injectObjectManager#'
111+
identifier: 'method.deprecatedInterface'
112+
path: src/UnitOfWork.php

src/Cache/DefaultCollectionHydrator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key,
5959
$targetRegion = $targetPersister->getCacheRegion();
6060
$list = [];
6161

62-
/** @var EntityCacheEntry[]|null $entityEntries */
62+
/**
63+
* @var EntityCacheEntry[]|null $entityEntries
64+
* @phpstan-ignore method.deprecatedInterface
65+
*/
6366
$entityEntries = $targetRegion->getMultiple($entry);
6467

6568
if ($entityEntries === null) {

src/Cache/DefaultQueryCache.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []
103103
};
104104

105105
$cacheKeys = new CollectionCacheEntry(array_map($generateKeys, $cacheEntry->result));
106-
$entries = $region->getMultiple($cacheKeys) ?? [];
106+
/** @phpstan-ignore method.deprecatedInterface */
107+
$entries = $region->getMultiple($cacheKeys) ?? [];
107108

108109
// @TODO - move to cache hydration component
109110
foreach ($cacheEntry->result as $index => $entry) {
@@ -167,8 +168,9 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []
167168
return new EntityCacheKey($assocMetadata->rootEntityName, $id);
168169
};
169170

170-
$collection = new PersistentCollection($this->em, $assocMetadata, new ArrayCollection());
171-
$assocKeys = new CollectionCacheEntry(array_map($generateKeys, $assoc['list']));
171+
$collection = new PersistentCollection($this->em, $assocMetadata, new ArrayCollection());
172+
$assocKeys = new CollectionCacheEntry(array_map($generateKeys, $assoc['list']));
173+
/** @phpstan-ignore method.deprecatedInterface */
172174
$assocEntries = $assocRegion->getMultiple($assocKeys);
173175

174176
foreach ($assoc['list'] as $assocIndex => $assocId) {

src/Cache/Region/FileLockRegion.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public function getMultiple(CollectionCacheEntry $collection)
156156
return null;
157157
}
158158

159+
/** @phpstan-ignore method.deprecatedInterface */
159160
return $this->region->getMultiple($collection);
160161
}
161162

src/Event/PreUpdateEventArgs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs
2828
*/
2929
public function __construct($entity, EntityManagerInterface $em, array &$changeSet)
3030
{
31-
// @phpstan-ignore staticMethod.deprecatedClass
31+
// @phpstan-ignore method.deprecatedClass
3232
parent::__construct($entity, $em);
3333

3434
$this->entityChangeSet = &$changeSet;

src/Mapping/ClassMetadataFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void
722722
'Mapping for %s: the "UUID" id generator strategy is deprecated with no replacement',
723723
$class->name
724724
);
725-
// @phpstan-ignore new.deprecated
725+
// @phpstan-ignore method.deprecatedClass, new.deprecatedClass
726726
$class->setIdGenerator(new UuidGenerator());
727727
break;
728728

src/Mapping/Driver/SimplifiedYamlDriver.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
* YamlDriver that additionally looks for mapping information in a global file.
1111
*
1212
* @deprecated This class is being removed from the ORM and won't have any replacement
13-
*
14-
* @phpstan-ignore class.extendsDeprecatedClass
1513
*/
1614
class SimplifiedYamlDriver extends YamlDriver
1715
{

0 commit comments

Comments
 (0)