Skip to content

Commit 1599975

Browse files
committed
Merge branch '2.10.x' into 2.11.x
* 2.10.x: Run static analysis with language level PHP 8.1 (doctrine#9314) Document PHPUnit mocks with intersection types (doctrine#9318)
2 parents 8c6fc5a + 44aa8c2 commit 1599975

17 files changed

+74
-82
lines changed

lib/Doctrine/ORM/LazyCriteriaCollection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Doctrine\Common\Collections\Criteria;
1010
use Doctrine\Common\Collections\Selectable;
1111
use Doctrine\ORM\Persisters\Entity\EntityPersister;
12+
use ReturnTypeWillChange;
1213

1314
/**
1415
* A lazy collection that allows a fast count when using criteria object
@@ -38,6 +39,7 @@ public function __construct(EntityPersister $entityPersister, Criteria $criteria
3839
*
3940
* @return int
4041
*/
42+
#[ReturnTypeWillChange]
4143
public function count()
4244
{
4345
if ($this->isInitialized()) {

lib/Doctrine/ORM/PersistentCollection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Doctrine\Common\Collections\Criteria;
1111
use Doctrine\Common\Collections\Selectable;
1212
use Doctrine\ORM\Mapping\ClassMetadata;
13+
use ReturnTypeWillChange;
1314
use RuntimeException;
1415

1516
use function array_combine;
@@ -504,6 +505,7 @@ public function offsetSet($offset, $value): void
504505
*
505506
* @return object|null
506507
*/
508+
#[ReturnTypeWillChange]
507509
public function offsetUnset($offset)
508510
{
509511
return $this->remove($offset);

phpstan-baseline.neon

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,6 @@ parameters:
265265
count: 2
266266
path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
267267

268-
-
269-
message: "#^Call to an undefined method ReflectionProperty\\:\\:getType\\(\\)\\.$#"
270-
count: 3
271-
path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
272-
273-
-
274-
message: "#^Call to an undefined method ReflectionProperty\\:\\:hasType\\(\\)\\.$#"
275-
count: 1
276-
path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
277-
278268
-
279269
message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\NamingStrategy\\:\\:joinColumnName\\(\\) invoked with 2 parameters, 1 required\\.$#"
280270
count: 2
@@ -1001,18 +991,17 @@ parameters:
1001991
path: lib/Doctrine/ORM/Query/Parser.php
1002992

1003993
-
1004-
message:
1005-
"""
1006-
#^PHPDoc tag @return has invalid value \\(AST\\\\BetweenExpression\\|
1007-
AST\\\\CollectionMemberExpression\\|
1008-
AST\\\\ComparisonExpression\\|
1009-
AST\\\\EmptyCollectionComparisonExpression\\|
1010-
AST\\\\ExistsExpression\\|
1011-
AST\\\\InExpression\\|
1012-
AST\\\\InstanceOfExpression\\|
1013-
AST\\\\LikeExpression\\|
1014-
AST\\\\NullComparisonExpression\\)\\: Unexpected token "\\\\n \\* ", expected type at offset 344$#
1015-
"""
994+
message: """
995+
#^PHPDoc tag @return has invalid value \\(AST\\\\BetweenExpression\\|
996+
AST\\\\CollectionMemberExpression\\|
997+
AST\\\\ComparisonExpression\\|
998+
AST\\\\EmptyCollectionComparisonExpression\\|
999+
AST\\\\ExistsExpression\\|
1000+
AST\\\\InExpression\\|
1001+
AST\\\\InstanceOfExpression\\|
1002+
AST\\\\LikeExpression\\|
1003+
AST\\\\NullComparisonExpression\\)\\: Unexpected token "\\\\n \\* ", expected type at offset 344$#
1004+
"""
10161005
count: 1
10171006
path: lib/Doctrine/ORM/Query/Parser.php
10181007

@@ -1915,4 +1904,3 @@ parameters:
19151904
message: "#^Access to an undefined property Doctrine\\\\Persistence\\\\Mapping\\\\ClassMetadata\\:\\:\\$subClasses\\.$#"
19161905
count: 1
19171906
path: lib/Doctrine/ORM/Utility/HierarchyDiscriminatorResolver.php
1918-

phpstan-params.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ parameters:
88
earlyTerminatingMethodCalls:
99
Doctrine\ORM\Query\Parser:
1010
- syntaxError
11-
phpVersion: 70100
11+
phpVersion: 80100

psalm.xml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0"?>
22
<psalm
33
errorLevel="2"
4+
phpVersion="8.1"
45
resolveFromConfigFile="true"
56
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
67
xmlns="https://getpsalm.org/schema/config"
@@ -102,25 +103,12 @@
102103
<file name="lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php"/>
103104
</errorLevel>
104105
</RedundantCondition>
105-
<!-- Workaround for https://github.com/vimeo/psalm/issues/7026 -->
106-
<ReservedWord>
107-
<errorLevel type="suppress">
108-
<directory name="lib"/>
109-
<directory name="tests"/>
110-
</errorLevel>
111-
</ReservedWord>
112106
<TypeDoesNotContainType>
113107
<errorLevel type="suppress">
114108
<file name="lib/Doctrine/ORM/Internal/SQLResultCasing.php"/>
115109
<file name="lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php"/>
116110
</errorLevel>
117111
</TypeDoesNotContainType>
118-
<UndefinedAttributeClass>
119-
<errorLevel type="suppress">
120-
<!-- The class was added in PHP 8.1 -->
121-
<referencedClass name="ReturnTypeWillChange"/>
122-
</errorLevel>
123-
</UndefinedAttributeClass>
124112
<UndefinedClass>
125113
<errorLevel type="suppress">
126114
<referencedClass name="Doctrine\Common\Cache\ApcCache"/>

tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CacheLoggerChainTest extends DoctrineTestCase
2121
/** @var CacheLoggerChain */
2222
private $logger;
2323

24-
/** @var MockObject|CacheLogger */
24+
/** @var CacheLogger&MockObject */
2525
private $mock;
2626

2727
protected function setUp(): void

tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Doctrine\Tests\OrmTestCase;
3232
use InvalidArgumentException;
3333
use LogicException;
34+
use PHPUnit\Framework\MockObject\MockObject;
3435

3536
use function assert;
3637

@@ -39,7 +40,7 @@
3940
*/
4041
class DefaultCacheFactoryTest extends OrmTestCase
4142
{
42-
/** @var CacheFactory */
43+
/** @var CacheFactory&MockObject */
4344
private $factory;
4445

4546
/** @var EntityManager */

tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
use Doctrine\ORM\Persisters\Collection\CollectionPersister;
1515
use Doctrine\Tests\Models\Cache\State;
1616
use Doctrine\Tests\OrmTestCase;
17+
use PHPUnit\Framework\MockObject\MockObject;
1718

1819
/**
1920
* @group DDC-2183
2021
*/
2122
abstract class AbstractCollectionPersisterTest extends OrmTestCase
2223
{
23-
/** @var Region */
24+
/** @var Region&MockObject */
2425
protected $region;
2526

2627
/** @var CollectionPersister */
@@ -70,6 +71,9 @@ protected function setUp(): void
7071
->getMock();
7172
}
7273

74+
/**
75+
* @return Region&MockObject
76+
*/
7377
protected function createRegion(): Region
7478
{
7579
return $this->getMockBuilder(Region::class)

tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717
use Doctrine\ORM\Query\ResultSetMappingBuilder;
1818
use Doctrine\Tests\Models\Cache\Country;
1919
use Doctrine\Tests\OrmTestCase;
20+
use PHPUnit\Framework\MockObject\MockObject;
2021

2122
/**
2223
* @group DDC-2183
2324
*/
2425
abstract class AbstractEntityPersisterTest extends OrmTestCase
2526
{
26-
/** @var Region */
27+
/** @var Region&MockObject */
2728
protected $region;
2829

29-
/** @var EntityPersister */
30+
/** @var EntityPersister&MockObject */
3031
protected $entityPersister;
3132

3233
/** @var EntityManager */
@@ -45,6 +46,9 @@ protected function setUp(): void
4546
$this->entityPersister = $this->createMock(EntityPersister::class);
4647
}
4748

49+
/**
50+
* @return Region&MockObject
51+
*/
4852
protected function createRegion(): Region
4953
{
5054
return $this->createMock(Region::class);

tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class EntityManagerDecoratorTest extends TestCase
3232
'lock',
3333
];
3434

35-
/** @var EntityManagerInterface|MockObject */
35+
/** @var EntityManagerInterface&MockObject */
3636
private $wrapped;
3737

3838
protected function setUp(): void

0 commit comments

Comments
 (0)