Skip to content

Commit b757374

Browse files
committed
Merged branch '4.6' into main
1 parent 4a57a51 commit b757374

File tree

6 files changed

+32
-90
lines changed

6 files changed

+32
-90
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ jobs:
9090
matrix:
9191
php:
9292
- '8.3'
93-
doctrine-persistence:
94-
- 'doctrine/persistence:^2.0'
95-
- 'doctrine/persistence:^3.0'
9693
image:
9794
- 'postgres:14'
9895
- 'postgres:18'
@@ -106,7 +103,6 @@ jobs:
106103
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
107104
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
108105
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}
109-
composer-options: "--with ${{ matrix.doctrine-persistence }}"
110106

111107
- name: Setup problem matchers for PHPUnit
112108
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
@@ -145,9 +141,6 @@ jobs:
145141
matrix:
146142
php:
147143
- '8.3'
148-
doctrine-persistence:
149-
- 'doctrine/persistence:^2.0'
150-
- 'doctrine/persistence:^3.0'
151144
image:
152145
- 'mysql:8.0'
153146
- 'mysql:8.4'
@@ -161,7 +154,6 @@ jobs:
161154
gh-client-secret: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
162155
satis-network-key: ${{ secrets.SATIS_NETWORK_KEY }}
163156
satis-network-token: ${{ secrets.SATIS_NETWORK_TOKEN }}
164-
composer-options: "--with ${{ matrix.doctrine-persistence }}"
165157

166158
- name: Setup problem matchers for PHPUnit
167159
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"doctrine/dbal": "^3.7.0",
2525
"doctrine/doctrine-bundle": "^2.11.0",
2626
"doctrine/orm": "^2.7",
27+
"doctrine/persistence": "^3.0",
2728
"friendsofphp/proxy-manager-lts": "^1.0",
2829
"friendsofsymfony/http-cache-bundle": "^3.0",
2930
"friendsofsymfony/jsrouting-bundle": "^3.5",

phpstan-baseline-doctrine-persistence-v2.neon

Lines changed: 0 additions & 7 deletions
This file was deleted.

phpstan-baseline-doctrine-persistence-v3.neon

Lines changed: 0 additions & 13 deletions
This file was deleted.

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10554,12 +10554,6 @@ parameters:
1055410554
count: 1
1055510555
path: src/lib/Persistence/Cache/UserPreferenceHandler.php
1055610556

10557-
-
10558-
message: '#^Return type \(Doctrine\\ORM\\Mapping\\ClassMetadataFactory\) of method Ibexa\\Core\\Persistence\\Doctrine\\SiteAccessAwareEntityManager\:\:getMetadataFactory\(\) should be compatible with return type \(Doctrine\\Persistence\\Mapping\\ClassMetadataFactory\<Doctrine\\Persistence\\Mapping\\ClassMetadata\<object\>\>\) of method Doctrine\\Persistence\\ObjectManager\:\:getMetadataFactory\(\)$#'
10559-
identifier: method.childReturnType
10560-
count: 2
10561-
path: src/lib/Persistence/Doctrine/SiteAccessAwareEntityManager.php
10562-
1056310557
-
1056410558
message: '#^Property Ibexa\\Core\\Persistence\\FieldTypeRegistry\:\:\$coreFieldTypes \(array\<Ibexa\\Contracts\\Core\\FieldType\\FieldType\>\) does not accept array\<Ibexa\\Core\\Persistence\\FieldType\>\.$#'
1056510559
identifier: assign.propertyType

src/lib/Persistence/Doctrine/SiteAccessAwareEntityManager.php

Lines changed: 31 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
namespace Ibexa\Core\Persistence\Doctrine;
1010

11+
use Doctrine\Common\EventManager;
1112
use Doctrine\DBAL\Connection;
1213
use Doctrine\ORM\Cache;
1314
use Doctrine\ORM\Configuration;
1415
use Doctrine\ORM\EntityManagerInterface;
1516
use Doctrine\ORM\EntityRepository;
1617
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
1718
use Doctrine\ORM\Mapping\ClassMetadata;
18-
use Doctrine\ORM\Mapping\ClassMetadataFactory;
1919
use Doctrine\ORM\NativeQuery;
2020
use Doctrine\ORM\Proxy\ProxyFactory;
2121
use Doctrine\ORM\Query;
@@ -24,15 +24,14 @@
2424
use Doctrine\ORM\Query\ResultSetMapping;
2525
use Doctrine\ORM\QueryBuilder;
2626
use Doctrine\ORM\UnitOfWork;
27+
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
2728
use Ibexa\Bundle\Core\Entity\EntityManagerFactory;
2829
use Ibexa\Contracts\Core\MVC\EventSubscriber\ConfigScopeChangeSubscriber;
2930
use Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent;
3031
use Symfony\Contracts\Service\ResetInterface;
3132

3233
/**
3334
* @internal
34-
*
35-
* SiteAccessAwareEntityManager is a cross-compatible class supporting doctrine/persistence v2 and v3.
3635
*/
3736
final class SiteAccessAwareEntityManager implements EntityManagerInterface, ConfigScopeChangeSubscriber, ResetInterface
3837
{
@@ -80,10 +79,7 @@ public function transactional($func)
8079
return $this->getWrapped()->transactional($func);
8180
}
8281

83-
/**
84-
* @return mixed
85-
*/
86-
public function wrapInTransaction(callable $func)
82+
public function wrapInTransaction(callable $func): mixed
8783
{
8884
return $this->getWrapped()->wrapInTransaction($func);
8985
}
@@ -129,6 +125,8 @@ public function createQueryBuilder(): QueryBuilder
129125
* @param class-string<T> $entityName
130126
*
131127
* @return T|null
128+
*
129+
* @throws \Doctrine\ORM\Exception\ORMException
132130
*/
133131
public function getReference($entityName, $id): ?object
134132
{
@@ -171,7 +169,7 @@ public function lock($entity, $lockMode, $lockVersion = null): void
171169
$this->getWrapped()->lock($entity, $lockMode, $lockVersion);
172170
}
173171

174-
public function getEventManager(): \Doctrine\Common\EventManager
172+
public function getEventManager(): EventManager
175173
{
176174
return $this->getWrapped()->getEventManager();
177175
}
@@ -231,36 +229,27 @@ public function find($className, $id): ?object
231229
return $this->getWrapped()->find($className, $id);
232230
}
233231

234-
/**
235-
* @param object $object
236-
*/
237-
public function persist($object): void
232+
public function persist(object $object): void
238233
{
239234
$this->getWrapped()->persist($object);
240235
}
241236

242-
public function remove($object): void
237+
public function remove(object $object): void
243238
{
244239
$this->getWrapped()->remove($object);
245240
}
246241

247-
/**
248-
* @param string|null $objectName
249-
*/
250-
public function clear($objectName = null): void
242+
public function clear(): void
251243
{
252-
$this->getWrapped()->clear($objectName);
244+
$this->getWrapped()->clear();
253245
}
254246

255-
/**
256-
* @param object $object
257-
*/
258-
public function detach($object): void
247+
public function detach(object $object): void
259248
{
260249
$this->getWrapped()->detach($object);
261250
}
262251

263-
public function refresh($object, ?int $lockMode = null): void
252+
public function refresh(object $object, ?int $lockMode = null): void
264253
{
265254
$this->getWrapped()->refresh($object, $lockMode);
266255
}
@@ -270,62 +259,48 @@ public function flush(): void
270259
$this->getWrapped()->flush();
271260
}
272261

262+
/**
263+
* @template T of object
264+
*
265+
* @param class-string<T> $className
266+
*
267+
* @return EntityRepository<T>
268+
*/
273269
public function getRepository($className): EntityRepository
274270
{
275271
return $this->getWrapped()->getRepository($className);
276272
}
277273

274+
/**
275+
* @template T of object
276+
*
277+
* @param class-string<T> $className
278+
*
279+
* @return ClassMetadata<T>
280+
*/
278281
public function getClassMetadata($className): ClassMetadata
279282
{
280283
return $this->getWrapped()->getClassMetadata($className);
281284
}
282285

283286
public function getMetadataFactory(): ClassMetadataFactory
284287
{
288+
/** @phpstan-var ClassMetadataFactory<\Doctrine\Persistence\Mapping\ClassMetadata<object>> */
285289
return $this->getWrapped()->getMetadataFactory();
286290
}
287291

288-
/**
289-
* @param object $obj
290-
*/
291-
public function initializeObject($obj): void
292+
public function initializeObject(object $obj): void
292293
{
293294
$this->getWrapped()->initializeObject($obj);
294295
}
295296

296-
/**
297-
* @param mixed $value
298-
*/
299-
public function isUninitializedObject($value): bool
297+
public function isUninitializedObject(mixed $value): bool
300298
{
301-
$entityManager = $this->getWrapped();
302-
303-
// workaround for doctrine/persistence v2 and v3 cross-compatibility
304-
return method_exists($entityManager, 'isUninitializedObject')
305-
? $entityManager->isUninitializedObject($value)
306-
: false;
299+
return $this->getWrapped()->isUninitializedObject($value);
307300
}
308301

309-
/**
310-
* @param object $object
311-
*/
312-
public function contains($object): bool
302+
public function contains(object $object): bool
313303
{
314304
return $this->getWrapped()->contains($object);
315305
}
316-
317-
/**
318-
* @param object $object
319-
*
320-
* @return object|null
321-
*/
322-
public function merge($object)
323-
{
324-
$entityManager = $this->getWrapped();
325-
326-
// workaround for doctrine/persistence v2 and v3 cross-compatibility
327-
return method_exists($entityManager, 'merge')
328-
? $entityManager->merge($object)
329-
: null;
330-
}
331306
}

0 commit comments

Comments
 (0)