Skip to content

Commit bf3e082

Browse files
committed
Merge branch '2.19.x' into 2.20.x
* 2.19.x: Psalm 5.24.0 (#11467) PHPStan 1.11.1 (#11466) Test with actual lock modes (#11465) Backport test for Query::setLockMode() (#11463)
2 parents eb49f66 + d31aabb commit bf3e082

File tree

4 files changed

+56
-12
lines changed

4 files changed

+56
-12
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
"doctrine/annotations": "^1.13 || ^2",
4343
"doctrine/coding-standard": "^9.0.2 || ^12.0",
4444
"phpbench/phpbench": "^0.16.10 || ^1.0",
45-
"phpstan/phpstan": "~1.4.10 || 1.10.59",
45+
"phpstan/phpstan": "~1.4.10 || 1.11.1",
4646
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.6",
4747
"psr/log": "^1 || ^2 || ^3",
4848
"squizlabs/php_codesniffer": "3.7.2",
4949
"symfony/cache": "^4.4 || ^5.4 || ^6.4 || ^7.0",
5050
"symfony/var-exporter": "^4.4 || ^5.4 || ^6.2 || ^7.0",
5151
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
52-
"vimeo/psalm": "4.30.0 || 5.22.2"
52+
"vimeo/psalm": "4.30.0 || 5.24.0"
5353
},
5454
"conflict": {
5555
"doctrine/annotations": "<1.13 || >= 3.0"

psalm-baseline.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
2+
<files psalm-version="5.24.0@462c80e31c34e58cc4f750c656be3927e80e550e">
33
<file src="src/AbstractQuery.php">
44
<DeprecatedClass>
55
<code><![CDATA[IterableResult]]></code>
@@ -380,6 +380,9 @@
380380
<code><![CDATA[serialize]]></code>
381381
<code><![CDATA[unserialize]]></code>
382382
</MethodSignatureMustProvideReturnType>
383+
<ParamNameMismatch>
384+
<code><![CDATA[$serialized]]></code>
385+
</ParamNameMismatch>
383386
</file>
384387
<file src="src/Id/TableGenerator.php">
385388
<PossiblyFalseOperand>
@@ -2341,9 +2344,6 @@
23412344
<InvalidReturnType>
23422345
<code><![CDATA[ObjectRepository]]></code>
23432346
</InvalidReturnType>
2344-
<TypeDoesNotContainType>
2345-
<code><![CDATA[$repository instanceof EntityRepository]]></code>
2346-
</TypeDoesNotContainType>
23472347
<UnsafeInstantiation>
23482348
<code><![CDATA[new $repositoryClassName($entityManager, $metadata)]]></code>
23492349
</UnsafeInstantiation>
@@ -2514,6 +2514,11 @@
25142514
<PossiblyNullArgument>
25152515
<code><![CDATA[$variableType]]></code>
25162516
</PossiblyNullArgument>
2517+
<PossiblyUndefinedArrayOffset>
2518+
<code><![CDATA[$fieldMapping['declaredField']]]></code>
2519+
<code><![CDATA[$fieldMapping['declaredField']]]></code>
2520+
<code><![CDATA[$fieldMapping['declaredField']]]></code>
2521+
</PossiblyUndefinedArrayOffset>
25172522
<PropertyNotSetInConstructor>
25182523
<code><![CDATA[$classToExtend]]></code>
25192524
</PropertyNotSetInConstructor>

tests/Tests/ORM/Cache/Persister/Entity/EntityPersisterTestCase.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Doctrine\Common\Collections\ArrayCollection;
88
use Doctrine\Common\Collections\Criteria;
9+
use Doctrine\DBAL\LockMode;
910
use Doctrine\ORM\Cache\Persister\CachedPersister;
1011
use Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister;
1112
use Doctrine\ORM\Cache\Persister\Entity\CachedEntityPersister;
@@ -99,7 +100,7 @@ public function testInvokeGetSelectSQL(): void
99100
->with(
100101
self::identicalTo(['name' => 'Foo']),
101102
self::identicalTo([0]),
102-
self::identicalTo(1),
103+
self::identicalTo(LockMode::OPTIMISTIC),
103104
self::identicalTo(2),
104105
self::identicalTo(3),
105106
self::identicalTo([4])
@@ -109,7 +110,7 @@ public function testInvokeGetSelectSQL(): void
109110
self::assertSame('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL(
110111
['name' => 'Foo'],
111112
[0],
112-
1,
113+
LockMode::OPTIMISTIC,
113114
2,
114115
3,
115116
[4]
@@ -228,13 +229,21 @@ public function testInvokeLoad(): void
228229
self::identicalTo($entity),
229230
self::identicalTo([0]),
230231
self::identicalTo([1]),
231-
self::identicalTo(2),
232+
self::identicalTo(LockMode::PESSIMISTIC_READ),
232233
self::identicalTo(3),
233234
self::identicalTo([4])
234235
)
235236
->willReturn($entity);
236237

237-
self::assertSame($entity, $persister->load(['id' => 1], $entity, [0], [1], 2, 3, [4]));
238+
self::assertSame($entity, $persister->load(
239+
['id' => 1],
240+
$entity,
241+
[0],
242+
[1],
243+
LockMode::PESSIMISTIC_READ,
244+
3,
245+
[4]
246+
));
238247
}
239248

240249
public function testInvokeLoadAll(): void
@@ -391,9 +400,9 @@ public function testInvokeLock(): void
391400

392401
$this->entityPersister->expects(self::once())
393402
->method('lock')
394-
->with(self::identicalTo($identifier), self::identicalTo(1));
403+
->with(self::identicalTo($identifier), self::identicalTo(LockMode::OPTIMISTIC));
395404

396-
$persister->lock($identifier, 1);
405+
$persister->lock($identifier, LockMode::OPTIMISTIC);
397406
}
398407

399408
public function testInvokeExists(): void

tests/Tests/ORM/Query/QueryTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
use Doctrine\DBAL\ArrayParameterType;
1414
use Doctrine\DBAL\Cache\QueryCacheProfile;
1515
use Doctrine\DBAL\Connection;
16+
use Doctrine\DBAL\LockMode;
1617
use Doctrine\DBAL\ParameterType;
1718
use Doctrine\DBAL\Types\Types;
1819
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
20+
use Doctrine\ORM\EntityManagerInterface;
1921
use Doctrine\ORM\Internal\Hydration\IterableResult;
22+
use Doctrine\ORM\Query;
2023
use Doctrine\ORM\Query\Parameter;
2124
use Doctrine\ORM\Query\QueryException;
2225
use Doctrine\ORM\UnitOfWork;
@@ -88,6 +91,33 @@ public function testSetParameters(): void
8891
self::assertEquals($parameters, $query->getParameters());
8992
}
9093

94+
/**
95+
* @psalm-param LockMode::* $lockMode
96+
*
97+
* @dataProvider provideLockModes
98+
*/
99+
public function testSetLockMode(int $lockMode): void
100+
{
101+
$query = $this->entityManager->wrapInTransaction(static function (EntityManagerInterface $em) use ($lockMode): Query {
102+
$query = $em->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1');
103+
$query->setLockMode($lockMode);
104+
105+
return $query;
106+
});
107+
108+
self::assertSame($lockMode, $query->getLockMode());
109+
self::assertSame($lockMode, $query->getHint(Query::HINT_LOCK_MODE));
110+
}
111+
112+
/** @psalm-return list<array{LockMode::*}> */
113+
public static function provideLockModes(): array
114+
{
115+
return [
116+
[LockMode::PESSIMISTIC_READ],
117+
[LockMode::PESSIMISTIC_WRITE],
118+
];
119+
}
120+
91121
public function testFree(): void
92122
{
93123
$query = $this->entityManager->createQuery('select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1');

0 commit comments

Comments
 (0)