Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 72a2aff

Browse filesBrowse files
bug #34955 Require doctrine/persistence ^1.3 (nicolas-grekas)
This PR was merged into the 4.3 branch. Discussion ---------- Require doctrine/persistence ^1.3 | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This is the only way to remove direct deprecations triggered by doctrine/persistence ^1.3. Requires v1.3.0 to be tagged before the next bug fix release. /cc @alcaeus The only deprecations that remain are triggered by the ORM now. Commits ------- ce5dcb9 Require doctrine/persistence ^1.3
2 parents 80d15cd + ce5dcb9 commit 72a2aff
Copy full SHA for 72a2aff
Expand file treeCollapse file tree

31 files changed

+67
-136
lines changed

‎composer.json

Copy file name to clipboardExpand all lines: composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": "^7.1.3",
2020
"ext-xml": "*",
2121
"doctrine/event-manager": "~1.0",
22-
"doctrine/persistence": "~1.0",
22+
"doctrine/persistence": "^1.3",
2323
"fig/link-util": "^1.0",
2424
"twig/twig": "^1.41|^2.10",
2525
"psr/cache": "~1.0",

‎src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\CacheWarmer;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
1514
use Doctrine\Persistence\ManagerRegistry;
1615
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
1716

@@ -27,10 +26,7 @@ class ProxyCacheWarmer implements CacheWarmerInterface
2726
{
2827
private $registry;
2928

30-
/**
31-
* @param ManagerRegistry|LegacyManagerRegistry $registry
32-
*/
33-
public function __construct($registry)
29+
public function __construct(ManagerRegistry $registry)
3430
{
3531
$this->registry = $registry;
3632
}

‎src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\DataCollector;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
1514
use Doctrine\DBAL\Logging\DebugStack;
1615
use Doctrine\DBAL\Types\ConversionException;
1716
use Doctrine\DBAL\Types\Type;
@@ -36,10 +35,7 @@ class DoctrineDataCollector extends DataCollector
3635
*/
3736
private $loggers = [];
3837

39-
/**
40-
* @param ManagerRegistry|LegacyManagerRegistry $registry
41-
*/
42-
public function __construct($registry)
38+
public function __construct(ManagerRegistry $registry)
4339
{
4440
$this->registry = $registry;
4541
$this->connections = $registry->getConnectionNames();

‎src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
1313

14-
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
1514
use Doctrine\Persistence\ObjectManager;
1615
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1716
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
@@ -41,12 +40,11 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
4140
* passed which optimizes the object loading for one of the Doctrine
4241
* mapper implementations.
4342
*
44-
* @param ObjectManager|LegacyObjectManager $manager The object manager
45-
* @param string $class The class name of the loaded objects
46-
* @param IdReader $idReader The reader for the object IDs
47-
* @param EntityLoaderInterface|null $objectLoader The objects loader
43+
* @param string $class The class name of the loaded objects
44+
* @param IdReader $idReader The reader for the object IDs
45+
* @param EntityLoaderInterface|null $objectLoader The objects loader
4846
*/
49-
public function __construct($manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null)
47+
public function __construct(ObjectManager $manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null)
5048
{
5149
$classMetadata = $manager->getClassMetadata($class);
5250

‎src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
1313

14-
use Doctrine\Common\Persistence\Mapping\ClassMetadata as LegacyClassMetadata;
15-
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
1614
use Doctrine\Persistence\Mapping\ClassMetadata;
1715
use Doctrine\Persistence\ObjectManager;
1816
use Symfony\Component\Form\Exception\RuntimeException;
@@ -37,11 +35,7 @@ class IdReader
3735
*/
3836
private $associationIdReader;
3937

40-
/**
41-
* @param ObjectManager|LegacyObjectManager $om
42-
* @param ClassMetadata|LegacyClassMetadata $classMetadata
43-
*/
44-
public function __construct($om, $classMetadata)
38+
public function __construct(ObjectManager $om, ClassMetadata $classMetadata)
4539
{
4640
$ids = $classMetadata->getIdentifierFieldNames();
4741
$idType = $classMetadata->getTypeOfField(current($ids));

‎src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
1514
use Doctrine\Persistence\ManagerRegistry;
1615
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
1716
use Symfony\Component\Form\AbstractExtension;
@@ -20,10 +19,7 @@ class DoctrineOrmExtension extends AbstractExtension
2019
{
2120
protected $registry;
2221

23-
/**
24-
* @param ManagerRegistry|LegacyManagerRegistry $registry
25-
*/
26-
public function __construct($registry)
22+
public function __construct(ManagerRegistry $registry)
2723
{
2824
$this->registry = $registry;
2925
}

‎src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
+4-13Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
15-
use Doctrine\Common\Persistence\Mapping\MappingException as LegacyCommonMappingException;
16-
use Doctrine\Common\Persistence\Proxy;
1714
use Doctrine\DBAL\Types\Type;
1815
use Doctrine\ORM\Mapping\ClassMetadataInfo;
1916
use Doctrine\ORM\Mapping\MappingException as LegacyMappingException;
2017
use Doctrine\Persistence\ManagerRegistry;
2118
use Doctrine\Persistence\Mapping\MappingException;
19+
use Doctrine\Persistence\Proxy;
2220
use Symfony\Component\Form\FormTypeGuesserInterface;
2321
use Symfony\Component\Form\Guess\Guess;
2422
use Symfony\Component\Form\Guess\TypeGuess;
@@ -30,10 +28,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
3028

3129
private $cache = [];
3230

33-
/**
34-
* @param ManagerRegistry|LegacyManagerRegistry $registry
35-
*/
36-
public function __construct($registry)
31+
public function __construct(ManagerRegistry $registry)
3732
{
3833
$this->registry = $registry;
3934
}
@@ -187,8 +182,6 @@ protected function getMetadata($class)
187182
return $this->cache[$class] = [$em->getClassMetadata($class), $name];
188183
} catch (MappingException $e) {
189184
// not an entity or mapped super class
190-
} catch (LegacyCommonMappingException $e) {
191-
// not an entity or mapped super class
192185
} catch (LegacyMappingException $e) {
193186
// not an entity or mapped super class, using Doctrine ORM 2.2
194187
}
@@ -199,12 +192,10 @@ protected function getMetadata($class)
199192

200193
private static function getRealClass(string $class): string
201194
{
202-
$marker = interface_exists(Proxy::class) ? '\\'.Proxy::MARKER.'\\' : '\__CG__\\';
203-
204-
if (false === $pos = strrpos($class, $marker)) {
195+
if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) {
205196
return $class;
206197
}
207198

208-
return substr($class, $pos + \strlen($marker));
199+
return substr($class, $pos + Proxy::MARKER_LENGTH + 2);
209200
}
210201
}

‎src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
+4-9Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\Bridge\Doctrine\Form\Type;
1313

1414
use Doctrine\Common\Collections\Collection;
15-
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
16-
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
1715
use Doctrine\Persistence\ManagerRegistry;
1816
use Doctrine\Persistence\ObjectManager;
1917
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
@@ -103,10 +101,7 @@ public function getQueryBuilderPartsForCachingHash($queryBuilder)
103101
return false;
104102
}
105103

106-
/**
107-
* @param ManagerRegistry|LegacyManagerRegistry $registry
108-
*/
109-
public function __construct($registry)
104+
public function __construct(ManagerRegistry $registry)
110105
{
111106
$this->registry = $registry;
112107
}
@@ -197,7 +192,7 @@ public function configureOptions(OptionsResolver $resolver)
197192

198193
$emNormalizer = function (Options $options, $em) {
199194
if (null !== $em) {
200-
if ($em instanceof ObjectManager || $em instanceof LegacyObjectManager) {
195+
if ($em instanceof ObjectManager) {
201196
return $em;
202197
}
203198

@@ -267,7 +262,7 @@ public function configureOptions(OptionsResolver $resolver)
267262
$resolver->setNormalizer('query_builder', $queryBuilderNormalizer);
268263
$resolver->setNormalizer('id_reader', $idReaderNormalizer);
269264

270-
$resolver->setAllowedTypes('em', ['null', 'string', ObjectManager::class, LegacyObjectManager::class]);
265+
$resolver->setAllowedTypes('em', ['null', 'string', ObjectManager::class]);
271266
}
272267

273268
/**
@@ -278,7 +273,7 @@ public function configureOptions(OptionsResolver $resolver)
278273
*
279274
* @return EntityLoaderInterface
280275
*/
281-
abstract public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class);
276+
abstract public function getLoader(ObjectManager $manager, $queryBuilder, $class);
282277

283278
public function getParent()
284279
{

‎src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form\Type;
1313

14-
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
1514
use Doctrine\ORM\Query\Parameter;
1615
use Doctrine\ORM\QueryBuilder;
16+
use Doctrine\Persistence\ObjectManager;
1717
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
1818
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1919
use Symfony\Component\OptionsResolver\Options;
@@ -51,7 +51,7 @@ public function configureOptions(OptionsResolver $resolver)
5151
*
5252
* @return ORMQueryBuilderLoader
5353
*/
54-
public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class)
54+
public function getLoader(ObjectManager $manager, $queryBuilder, $class)
5555
{
5656
return new ORMQueryBuilderLoader($queryBuilder);
5757
}

‎src/Symfony/Bridge/Doctrine/ManagerRegistry.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/ManagerRegistry.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine;
1313

14-
use Doctrine\Common\Persistence\AbstractManagerRegistry as LegacyAbstractManagerRegistry;
14+
use Doctrine\Persistence\AbstractManagerRegistry;
1515
use ProxyManager\Proxy\LazyLoadingInterface;
1616
use Symfony\Component\DependencyInjection\Container;
1717

@@ -20,7 +20,7 @@
2020
*
2121
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
2222
*/
23-
abstract class ManagerRegistry extends LegacyAbstractManagerRegistry
23+
abstract class ManagerRegistry extends AbstractManagerRegistry
2424
{
2525
/**
2626
* @var Container

‎src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\PropertyInfo;
1313

14-
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory as LegacyClassMetadataFactory;
15-
use Doctrine\Common\Persistence\Mapping\MappingException as LegacyMappingException;
1614
use Doctrine\DBAL\Types\Type as DBALType;
1715
use Doctrine\ORM\EntityManagerInterface;
1816
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -42,7 +40,7 @@ public function __construct($entityManager)
4240
{
4341
if ($entityManager instanceof EntityManagerInterface) {
4442
$this->entityManager = $entityManager;
45-
} elseif ($entityManager instanceof ClassMetadataFactory || $entityManager instanceof LegacyClassMetadataFactory) {
43+
} elseif ($entityManager instanceof ClassMetadataFactory) {
4644
@trigger_error(sprintf('Injecting an instance of "%s" in "%s" is deprecated since Symfony 4.2, inject an instance of "%s" instead.', ClassMetadataFactory::class, __CLASS__, EntityManagerInterface::class), E_USER_DEPRECATED);
4745
$this->classMetadataFactory = $entityManager;
4846
} else {
@@ -202,7 +200,7 @@ private function getMetadata(string $class): ?ClassMetadata
202200
{
203201
try {
204202
return $this->entityManager ? $this->entityManager->getClassMetadata($class) : $this->classMetadataFactory->getMetadataFor($class);
205-
} catch (MappingException | OrmMappingException | LegacyMappingException $exception) {
203+
} catch (MappingException | OrmMappingException $exception) {
206204
return null;
207205
}
208206
}

‎src/Symfony/Bridge/Doctrine/RegistryInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/RegistryInterface.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111

1212
namespace Symfony\Bridge\Doctrine;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
1514
use Doctrine\ORM\EntityManager;
15+
use Doctrine\Persistence\ManagerRegistry;
1616

1717
/**
1818
* References Doctrine connections and entity managers.
1919
*
2020
* @author Fabien Potencier <fabien@symfony.com>
2121
*/
22-
interface RegistryInterface extends LegacyManagerRegistry
22+
interface RegistryInterface extends ManagerRegistry
2323
{
2424
/**
2525
* Gets the default entity manager name.

‎src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Security\User;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
1514
use Doctrine\Persistence\ManagerRegistry;
15+
use Doctrine\Persistence\Mapping\ClassMetadata;
16+
use Doctrine\Persistence\ObjectManager;
17+
use Doctrine\Persistence\ObjectRepository;
1618
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
1719
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
1820
use Symfony\Component\Security\Core\User\UserInterface;
@@ -34,10 +36,7 @@ class EntityUserProvider implements UserProviderInterface
3436
private $class;
3537
private $property;
3638

37-
/**
38-
* @param ManagerRegistry|LegacyManagerRegistry $registry
39-
*/
40-
public function __construct($registry, string $classOrAlias, string $property = null, string $managerName = null)
39+
public function __construct(ManagerRegistry $registry, string $classOrAlias, string $property = null, string $managerName = null)
4140
{
4241
$this->registry = $registry;
4342
$this->managerName = $managerName;
@@ -107,17 +106,17 @@ public function supportsClass($class)
107106
return $class === $this->getClass() || is_subclass_of($class, $this->getClass());
108107
}
109108

110-
private function getObjectManager()
109+
private function getObjectManager(): ObjectManager
111110
{
112111
return $this->registry->getManager($this->managerName);
113112
}
114113

115-
private function getRepository()
114+
private function getRepository(): ObjectRepository
116115
{
117116
return $this->getObjectManager()->getRepository($this->classOrAlias);
118117
}
119118

120-
private function getClass()
119+
private function getClass(): string
121120
{
122121
if (null === $this->class) {
123122
$class = $this->classOrAlias;
@@ -132,7 +131,7 @@ private function getClass()
132131
return $this->class;
133132
}
134133

135-
private function getClassMetadata()
134+
private function getClassMetadata(): ClassMetadata
136135
{
137136
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
138137
}

‎src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
use Doctrine\Common\Annotations\AnnotationReader;
1515
use Doctrine\Common\Cache\ArrayCache;
16-
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain as LegacyMappingDriverChain;
17-
use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator as LegacySymfonyFileLocator;
1816
use Doctrine\ORM\Configuration;
1917
use Doctrine\ORM\EntityManager;
2018
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
@@ -76,13 +74,11 @@ public static function createTestConfiguration()
7674
public static function createTestConfigurationWithXmlLoader()
7775
{
7876
$config = static::createTestConfiguration();
79-
$symfonyFileLocator = class_exists(SymfonyFileLocator::class) ? SymfonyFileLocator::class : LegacySymfonyFileLocator::class;
80-
$driverChain = class_exists(MappingDriverChain::class) ? MappingDriverChain::class : LegacyMappingDriverChain::class;
8177

82-
$driverChain = new $driverChain();
78+
$driverChain = new MappingDriverChain();
8379
$driverChain->addDriver(
8480
new XmlDriver(
85-
new $symfonyFileLocator(
81+
new SymfonyFileLocator(
8682
[__DIR__.'/../Tests/Resources/orm' => 'Symfony\\Bridge\\Doctrine\\Tests\\Fixtures'], '.orm.xml'
8783
)
8884
),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.