Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 61c1d96

Browse files
Require doctrine/persistence ^1.3
1 parent 80d15cd commit 61c1d96

30 files changed

+63
-129
lines changed

composer.json

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
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;
1614
use Doctrine\Common\Persistence\Proxy;
1715
use Doctrine\DBAL\Types\Type;
1816
use Doctrine\ORM\Mapping\ClassMetadataInfo;
@@ -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
}

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

Lines 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

Lines 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

Lines 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 <[email protected]>
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

Lines 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

Lines 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;
14+
use Doctrine\Persistence\ManagerRegistry;
1515
use Doctrine\ORM\EntityManager;
1616

1717
/**
1818
* References Doctrine connections and entity managers.
1919
*
2020
* @author Fabien Potencier <[email protected]>
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

Lines 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

Lines 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
),

src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Test;
1313

14-
use Doctrine\Common\Persistence\ObjectRepository as LegacyObjectRepository;
1514
use Doctrine\ORM\EntityManagerInterface;
1615
use Doctrine\ORM\Mapping\ClassMetadata;
1716
use Doctrine\ORM\Repository\RepositoryFactory;
@@ -30,7 +29,7 @@ final class TestRepositoryFactory implements RepositoryFactory
3029
/**
3130
* {@inheritdoc}
3231
*
33-
* @return ObjectRepository|LegacyObjectRepository
32+
* @return ObjectRepository
3433
*/
3534
public function getRepository(EntityManagerInterface $entityManager, $entityName)
3635
{
@@ -43,17 +42,14 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName
4342
return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName);
4443
}
4544

46-
public function setRepository(EntityManagerInterface $entityManager, $entityName, LegacyObjectRepository $repository)
45+
public function setRepository(EntityManagerInterface $entityManager, $entityName, ObjectRepository $repository)
4746
{
4847
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
4948

5049
$this->repositoryList[$repositoryHash] = $repository;
5150
}
5251

53-
/**
54-
* @return ObjectRepository|LegacyObjectRepository
55-
*/
56-
private function createRepository(EntityManagerInterface $entityManager, string $entityName)
52+
private function createRepository(EntityManagerInterface $entityManager, string $entityName): ObjectRepository
5753
{
5854
/* @var $metadata ClassMetadata */
5955
$metadata = $entityManager->getClassMetadata($entityName);

0 commit comments

Comments
 (0)