From ce5dcb96c1639df2c49d6a1f253b8b15b5aa90ea Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 12 Dec 2019 15:22:57 +0100 Subject: [PATCH] Require doctrine/persistence ^1.3 --- composer.json | 2 +- .../Doctrine/CacheWarmer/ProxyCacheWarmer.php | 6 +----- .../DataCollector/DoctrineDataCollector.php | 6 +----- .../Form/ChoiceList/DoctrineChoiceLoader.php | 10 ++++------ .../Doctrine/Form/ChoiceList/IdReader.php | 8 +------- .../Doctrine/Form/DoctrineOrmExtension.php | 6 +----- .../Doctrine/Form/DoctrineOrmTypeGuesser.php | 17 ++++------------- .../Bridge/Doctrine/Form/Type/DoctrineType.php | 13 ++++--------- .../Bridge/Doctrine/Form/Type/EntityType.php | 4 ++-- src/Symfony/Bridge/Doctrine/ManagerRegistry.php | 4 ++-- .../Doctrine/PropertyInfo/DoctrineExtractor.php | 6 ++---- .../Bridge/Doctrine/RegistryInterface.php | 4 ++-- .../Security/User/EntityUserProvider.php | 17 ++++++++--------- .../Bridge/Doctrine/Test/DoctrineTestHelper.php | 8 ++------ .../Doctrine/Test/TestRepositoryFactory.php | 10 +++------- .../DataCollector/DoctrineDataCollectorTest.php | 3 +-- .../Tests/Fixtures/ContainerAwareFixture.php | 4 ++-- .../ChoiceList/DoctrineChoiceLoaderTest.php | 8 +++----- .../Tests/Form/DoctrineOrmTypeGuesserTest.php | 6 ++---- .../Form/Type/EntityTypePerformanceTest.php | 3 +-- .../Doctrine/Tests/Form/Type/EntityTypeTest.php | 3 +-- .../Security/User/EntityUserProviderTest.php | 16 +++++++--------- .../Constraints/UniqueEntityValidatorTest.php | 12 ++++-------- .../Constraints/UniqueEntityValidator.php | 6 +----- .../Doctrine/Validator/DoctrineInitializer.php | 6 +----- src/Symfony/Bridge/Doctrine/composer.json | 2 +- .../Controller/AbstractController.php | 3 +-- .../Controller/ControllerTrait.php | 3 +-- .../Tests/Controller/AbstractControllerTest.php | 3 +-- .../Tests/Controller/ControllerTraitTest.php | 3 +-- .../Bundle/FrameworkBundle/composer.json | 1 + 31 files changed, 67 insertions(+), 136 deletions(-) diff --git a/composer.json b/composer.json index a379c17200f74..40d02efe38782 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": "^7.1.3", "ext-xml": "*", "doctrine/event-manager": "~1.0", - "doctrine/persistence": "~1.0", + "doctrine/persistence": "^1.3", "fig/link-util": "^1.0", "twig/twig": "^1.41|^2.10", "psr/cache": "~1.0", diff --git a/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php b/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php index db8163e4c8b43..24cf25be59f3d 100644 --- a/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php +++ b/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\CacheWarmer; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\Persistence\ManagerRegistry; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; @@ -27,10 +26,7 @@ class ProxyCacheWarmer implements CacheWarmerInterface { private $registry; - /** - * @param ManagerRegistry|LegacyManagerRegistry $registry - */ - public function __construct($registry) + public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } diff --git a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php index 991d44c8ee1e9..c30e92993e677 100644 --- a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php +++ b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\DataCollector; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; @@ -36,10 +35,7 @@ class DoctrineDataCollector extends DataCollector */ private $loggers = []; - /** - * @param ManagerRegistry|LegacyManagerRegistry $registry - */ - public function __construct($registry) + public function __construct(ManagerRegistry $registry) { $this->registry = $registry; $this->connections = $registry->getConnectionNames(); diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php index d00c66e1b52b8..473d68ebf7be1 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\Form\ChoiceList; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; use Doctrine\Persistence\ObjectManager; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; @@ -41,12 +40,11 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface * passed which optimizes the object loading for one of the Doctrine * mapper implementations. * - * @param ObjectManager|LegacyObjectManager $manager The object manager - * @param string $class The class name of the loaded objects - * @param IdReader $idReader The reader for the object IDs - * @param EntityLoaderInterface|null $objectLoader The objects loader + * @param string $class The class name of the loaded objects + * @param IdReader $idReader The reader for the object IDs + * @param EntityLoaderInterface|null $objectLoader The objects loader */ - public function __construct($manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null) + public function __construct(ObjectManager $manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null) { $classMetadata = $manager->getClassMetadata($class); diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php index f6e60f5540e35..f56193e81062f 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php @@ -11,8 +11,6 @@ namespace Symfony\Bridge\Doctrine\Form\ChoiceList; -use Doctrine\Common\Persistence\Mapping\ClassMetadata as LegacyClassMetadata; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\ObjectManager; use Symfony\Component\Form\Exception\RuntimeException; @@ -37,11 +35,7 @@ class IdReader */ private $associationIdReader; - /** - * @param ObjectManager|LegacyObjectManager $om - * @param ClassMetadata|LegacyClassMetadata $classMetadata - */ - public function __construct($om, $classMetadata) + public function __construct(ObjectManager $om, ClassMetadata $classMetadata) { $ids = $classMetadata->getIdentifierFieldNames(); $idType = $classMetadata->getTypeOfField(current($ids)); diff --git a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php index 90aca67a49fb6..c2897c6d9aba8 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php +++ b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\Form; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\Persistence\ManagerRegistry; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractExtension; @@ -20,10 +19,7 @@ class DoctrineOrmExtension extends AbstractExtension { protected $registry; - /** - * @param ManagerRegistry|LegacyManagerRegistry $registry - */ - public function __construct($registry) + public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } diff --git a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php index 765574d018812..6b097087b1e23 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php +++ b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php @@ -11,14 +11,12 @@ namespace Symfony\Bridge\Doctrine\Form; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; -use Doctrine\Common\Persistence\Mapping\MappingException as LegacyCommonMappingException; -use Doctrine\Common\Persistence\Proxy; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException as LegacyMappingException; use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\Mapping\MappingException; +use Doctrine\Persistence\Proxy; use Symfony\Component\Form\FormTypeGuesserInterface; use Symfony\Component\Form\Guess\Guess; use Symfony\Component\Form\Guess\TypeGuess; @@ -30,10 +28,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface private $cache = []; - /** - * @param ManagerRegistry|LegacyManagerRegistry $registry - */ - public function __construct($registry) + public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } @@ -187,8 +182,6 @@ protected function getMetadata($class) return $this->cache[$class] = [$em->getClassMetadata($class), $name]; } catch (MappingException $e) { // not an entity or mapped super class - } catch (LegacyCommonMappingException $e) { - // not an entity or mapped super class } catch (LegacyMappingException $e) { // not an entity or mapped super class, using Doctrine ORM 2.2 } @@ -199,12 +192,10 @@ protected function getMetadata($class) private static function getRealClass(string $class): string { - $marker = interface_exists(Proxy::class) ? '\\'.Proxy::MARKER.'\\' : '\__CG__\\'; - - if (false === $pos = strrpos($class, $marker)) { + if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) { return $class; } - return substr($class, $pos + \strlen($marker)); + return substr($class, $pos + Proxy::MARKER_LENGTH + 2); } } diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index dee38d187b88e..65a3368ba2156 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -12,8 +12,6 @@ namespace Symfony\Bridge\Doctrine\Form\Type; use Doctrine\Common\Collections\Collection; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ObjectManager; use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader; @@ -103,10 +101,7 @@ public function getQueryBuilderPartsForCachingHash($queryBuilder) return false; } - /** - * @param ManagerRegistry|LegacyManagerRegistry $registry - */ - public function __construct($registry) + public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } @@ -197,7 +192,7 @@ public function configureOptions(OptionsResolver $resolver) $emNormalizer = function (Options $options, $em) { if (null !== $em) { - if ($em instanceof ObjectManager || $em instanceof LegacyObjectManager) { + if ($em instanceof ObjectManager) { return $em; } @@ -267,7 +262,7 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setNormalizer('query_builder', $queryBuilderNormalizer); $resolver->setNormalizer('id_reader', $idReaderNormalizer); - $resolver->setAllowedTypes('em', ['null', 'string', ObjectManager::class, LegacyObjectManager::class]); + $resolver->setAllowedTypes('em', ['null', 'string', ObjectManager::class]); } /** @@ -278,7 +273,7 @@ public function configureOptions(OptionsResolver $resolver) * * @return EntityLoaderInterface */ - abstract public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class); + abstract public function getLoader(ObjectManager $manager, $queryBuilder, $class); public function getParent() { diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php index fdfb18ed01a5c..f48b7f2f0cf82 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Form\Type; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\QueryBuilder; +use Doctrine\Persistence\ObjectManager; use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\OptionsResolver\Options; @@ -51,7 +51,7 @@ public function configureOptions(OptionsResolver $resolver) * * @return ORMQueryBuilderLoader */ - public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class) + public function getLoader(ObjectManager $manager, $queryBuilder, $class) { return new ORMQueryBuilderLoader($queryBuilder); } diff --git a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php index ac04863d3ce79..a19be6a0c4071 100644 --- a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php +++ b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php @@ -11,7 +11,7 @@ namespace Symfony\Bridge\Doctrine; -use Doctrine\Common\Persistence\AbstractManagerRegistry as LegacyAbstractManagerRegistry; +use Doctrine\Persistence\AbstractManagerRegistry; use ProxyManager\Proxy\LazyLoadingInterface; use Symfony\Component\DependencyInjection\Container; @@ -20,7 +20,7 @@ * * @author Lukas Kahwe Smith */ -abstract class ManagerRegistry extends LegacyAbstractManagerRegistry +abstract class ManagerRegistry extends AbstractManagerRegistry { /** * @var Container diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index 57e129df0e0ca..a64f868915143 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -11,8 +11,6 @@ namespace Symfony\Bridge\Doctrine\PropertyInfo; -use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory as LegacyClassMetadataFactory; -use Doctrine\Common\Persistence\Mapping\MappingException as LegacyMappingException; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; @@ -42,7 +40,7 @@ public function __construct($entityManager) { if ($entityManager instanceof EntityManagerInterface) { $this->entityManager = $entityManager; - } elseif ($entityManager instanceof ClassMetadataFactory || $entityManager instanceof LegacyClassMetadataFactory) { + } elseif ($entityManager instanceof ClassMetadataFactory) { @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); $this->classMetadataFactory = $entityManager; } else { @@ -202,7 +200,7 @@ private function getMetadata(string $class): ?ClassMetadata { try { return $this->entityManager ? $this->entityManager->getClassMetadata($class) : $this->classMetadataFactory->getMetadataFor($class); - } catch (MappingException | OrmMappingException | LegacyMappingException $exception) { + } catch (MappingException | OrmMappingException $exception) { return null; } } diff --git a/src/Symfony/Bridge/Doctrine/RegistryInterface.php b/src/Symfony/Bridge/Doctrine/RegistryInterface.php index e5b0c6f573ab9..5fc792ca0cc23 100644 --- a/src/Symfony/Bridge/Doctrine/RegistryInterface.php +++ b/src/Symfony/Bridge/Doctrine/RegistryInterface.php @@ -11,15 +11,15 @@ namespace Symfony\Bridge\Doctrine; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\ORM\EntityManager; +use Doctrine\Persistence\ManagerRegistry; /** * References Doctrine connections and entity managers. * * @author Fabien Potencier */ -interface RegistryInterface extends LegacyManagerRegistry +interface RegistryInterface extends ManagerRegistry { /** * Gets the default entity manager name. diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index 6c666ee849fc0..7df455abf4192 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -11,8 +11,10 @@ namespace Symfony\Bridge\Doctrine\Security\User; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\Persistence\ManagerRegistry; +use Doctrine\Persistence\Mapping\ClassMetadata; +use Doctrine\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectRepository; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\User\UserInterface; @@ -34,10 +36,7 @@ class EntityUserProvider implements UserProviderInterface private $class; private $property; - /** - * @param ManagerRegistry|LegacyManagerRegistry $registry - */ - public function __construct($registry, string $classOrAlias, string $property = null, string $managerName = null) + public function __construct(ManagerRegistry $registry, string $classOrAlias, string $property = null, string $managerName = null) { $this->registry = $registry; $this->managerName = $managerName; @@ -107,17 +106,17 @@ public function supportsClass($class) return $class === $this->getClass() || is_subclass_of($class, $this->getClass()); } - private function getObjectManager() + private function getObjectManager(): ObjectManager { return $this->registry->getManager($this->managerName); } - private function getRepository() + private function getRepository(): ObjectRepository { return $this->getObjectManager()->getRepository($this->classOrAlias); } - private function getClass() + private function getClass(): string { if (null === $this->class) { $class = $this->classOrAlias; @@ -132,7 +131,7 @@ private function getClass() return $this->class; } - private function getClassMetadata() + private function getClassMetadata(): ClassMetadata { return $this->getObjectManager()->getClassMetadata($this->classOrAlias); } diff --git a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php index 5c9a7741c5867..2ad16dcd4de24 100644 --- a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php +++ b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php @@ -13,8 +13,6 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Cache\ArrayCache; -use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain as LegacyMappingDriverChain; -use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator as LegacySymfonyFileLocator; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; @@ -76,13 +74,11 @@ public static function createTestConfiguration() public static function createTestConfigurationWithXmlLoader() { $config = static::createTestConfiguration(); - $symfonyFileLocator = class_exists(SymfonyFileLocator::class) ? SymfonyFileLocator::class : LegacySymfonyFileLocator::class; - $driverChain = class_exists(MappingDriverChain::class) ? MappingDriverChain::class : LegacyMappingDriverChain::class; - $driverChain = new $driverChain(); + $driverChain = new MappingDriverChain(); $driverChain->addDriver( new XmlDriver( - new $symfonyFileLocator( + new SymfonyFileLocator( [__DIR__.'/../Tests/Resources/orm' => 'Symfony\\Bridge\\Doctrine\\Tests\\Fixtures'], '.orm.xml' ) ), diff --git a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php index f71656714eb5e..f98cba4cefa4d 100644 --- a/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php +++ b/src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\Test; -use Doctrine\Common\Persistence\ObjectRepository as LegacyObjectRepository; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Repository\RepositoryFactory; @@ -30,7 +29,7 @@ final class TestRepositoryFactory implements RepositoryFactory /** * {@inheritdoc} * - * @return ObjectRepository|LegacyObjectRepository + * @return ObjectRepository */ public function getRepository(EntityManagerInterface $entityManager, $entityName) { @@ -43,17 +42,14 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName); } - public function setRepository(EntityManagerInterface $entityManager, $entityName, LegacyObjectRepository $repository) + public function setRepository(EntityManagerInterface $entityManager, $entityName, ObjectRepository $repository) { $repositoryHash = $this->getRepositoryHash($entityManager, $entityName); $this->repositoryList[$repositoryHash] = $repository; } - /** - * @return ObjectRepository|LegacyObjectRepository - */ - private function createRepository(EntityManagerInterface $entityManager, string $entityName) + private function createRepository(EntityManagerInterface $entityManager, string $entityName): ObjectRepository { /* @var $metadata ClassMetadata */ $metadata = $entityManager->getClassMetadata($entityName); diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php index 323302eb51cd2..0e478d6a794b8 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\Tests\DataCollector; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Version; use Doctrine\Persistence\ManagerRegistry; @@ -182,7 +181,7 @@ private function createCollector($queries) ->method('getDatabasePlatform') ->willReturn(new MySqlPlatform()); - $registry = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock(); + $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock(); $registry ->expects($this->any()) ->method('getConnectionNames') diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php index 7d183351cefe9..6655033ab4999 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php @@ -12,7 +12,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; use Doctrine\Common\DataFixtures\FixtureInterface; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; +use Doctrine\Persistence\ObjectManager; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -25,7 +25,7 @@ public function setContainer(ContainerInterface $container = null) $this->container = $container; } - public function load(LegacyObjectManager $manager) + public function load(ObjectManager $manager) { } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php index 5c91d54de695d..ee9597ed4975a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php @@ -11,8 +11,6 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; -use Doctrine\Common\Persistence\ObjectRepository as LegacyObjectRepository; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectRepository; @@ -78,8 +76,8 @@ class DoctrineChoiceLoaderTest extends TestCase protected function setUp(): void { $this->factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock(); - $this->om = $this->getMockBuilder(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class)->getMock(); - $this->repository = $this->getMockBuilder(interface_exists(ObjectRepository::class) ? ObjectRepository::class : LegacyObjectRepository::class)->getMock(); + $this->om = $this->getMockBuilder(ObjectManager::class)->getMock(); + $this->repository = $this->getMockBuilder(ObjectRepository::class)->getMock(); $this->class = 'stdClass'; $this->idReader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader') ->disableOriginalConstructor() @@ -408,7 +406,7 @@ public function testLoaderWithoutIdReaderCanBeOptimized() }) ; - $this->om = $this->createMock(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class); + $this->om = $this->createMock(ObjectManager::class); $this->om->expects($this->once()) ->method('getClassMetadata') ->with(SingleIntIdEntity::class) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index 226f94e9934cf..50f222d8e8c59 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -11,8 +11,6 @@ namespace Symfony\Bridge\Doctrine\Tests\Form; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ObjectManager; @@ -87,10 +85,10 @@ public function requiredProvider() private function getGuesser(ClassMetadata $classMetadata) { - $em = $this->getMockBuilder(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class)->getMock(); + $em = $this->getMockBuilder(ObjectManager::class)->getMock(); $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->willReturn($classMetadata); - $registry = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock(); + $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock(); $registry->expects($this->once())->method('getManagers')->willReturn([$em]); return new DoctrineOrmTypeGuesser($registry); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index e4ba871ba99e1..23b39b3674cb0 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\Type; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\ManagerRegistry; use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension; @@ -36,7 +35,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase protected function getExtensions() { - $manager = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock(); + $manager = $this->getMockBuilder(ManagerRegistry::class)->getMock(); $manager->expects($this->any()) ->method('getManager') diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index dd07120cf51f9..542e3f341d85a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -12,7 +12,6 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\Type; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Tools\SchemaTool; @@ -1229,7 +1228,7 @@ public function testLoaderCachingWithParameters() protected function createRegistryMock($name, $em) { - $registry = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock(); + $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock(); $registry->expects($this->any()) ->method('getManager') ->with($this->equalTo($name)) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 92a86d48d85d9..c613495922417 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -11,13 +11,13 @@ namespace Symfony\Bridge\Doctrine\Tests\Security\User; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectRepository; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider; +use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Tests\Fixtures\User; @@ -62,9 +62,7 @@ public function testLoadUserByUsernameWithUserLoaderRepositoryAndWithoutProperty { $user = new User(1, 1, 'user1'); - $repository = $this->getMockBuilder('Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface') - ->disableOriginalConstructor() - ->getMock(); + $repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]); $repository ->expects($this->once()) ->method('loadUserByUsername') @@ -150,7 +148,7 @@ public function testSupportProxy() public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided() { - $repository = $this->getMockBuilder('\Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')->getMock(); + $repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]); $repository->expects($this->once()) ->method('loadUserByUsername') ->with('name') @@ -169,7 +167,7 @@ public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided( public function testLoadUserByUserNameShouldDeclineInvalidInterface() { $this->expectException('InvalidArgumentException'); - $repository = $this->getMockBuilder('\Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $repository = $this->createMock(ObjectRepository::class); $provider = new EntityUserProvider( $this->getManager($this->getObjectManager($repository)), @@ -181,7 +179,7 @@ public function testLoadUserByUserNameShouldDeclineInvalidInterface() private function getManager($em, $name = null) { - $manager = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock(); + $manager = $this->getMockBuilder(ManagerRegistry::class)->getMock(); $manager->expects($this->any()) ->method('getManager') ->with($this->equalTo($name)) @@ -192,7 +190,7 @@ private function getManager($em, $name = null) private function getObjectManager($repository) { - $em = $this->getMockBuilder(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class) + $em = $this->getMockBuilder(ObjectManager::class) ->setMethods(['getClassMetadata', 'getRepository']) ->getMockForAbstractClass(); $em->expects($this->any()) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index ecbc58da4eed5..e9e905c89c3a4 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -12,10 +12,6 @@ namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; -use Doctrine\Common\Persistence\Mapping\ClassMetadata as LegacyClassMetadata; -use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager; -use Doctrine\Common\Persistence\ObjectRepository as LegacyObjectRepository; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Persistence\ManagerRegistry; @@ -83,7 +79,7 @@ protected function setUp(): void protected function createRegistryMock($em = null) { - $registry = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock(); + $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock(); $registry->expects($this->any()) ->method('getManager') ->with($this->equalTo(self::EM_NAME)) @@ -94,7 +90,7 @@ protected function createRegistryMock($em = null) protected function createRepositoryMock() { - $repository = $this->getMockBuilder(interface_exists(ObjectRepository::class) ? ObjectRepository::class : LegacyObjectRepository::class) + $repository = $this->getMockBuilder(ObjectRepository::class) ->setMethods(['findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName']) ->getMock() ; @@ -104,7 +100,7 @@ protected function createRepositoryMock() protected function createEntityManagerMock($repositoryMock) { - $em = $this->getMockBuilder(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class) + $em = $this->getMockBuilder(ObjectManager::class) ->getMock() ; $em->expects($this->any()) @@ -112,7 +108,7 @@ protected function createEntityManagerMock($repositoryMock) ->willReturn($repositoryMock) ; - $classMetadata = $this->getMockBuilder(interface_exists(ClassMetadata::class) ? ClassMetadata::class : LegacyClassMetadata::class)->getMock(); + $classMetadata = $this->getMockBuilder(ClassMetadata::class)->getMock(); $classMetadata ->expects($this->any()) ->method('hasField') diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index d6b9eb5de8cbb..503f99c5b2a2b 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\Validator\Constraints; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\Persistence\ManagerRegistry; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; @@ -27,10 +26,7 @@ class UniqueEntityValidator extends ConstraintValidator { private $registry; - /** - * @param ManagerRegistry|LegacyManagerRegistry $registry - */ - public function __construct($registry) + public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } diff --git a/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php b/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php index b337be5b1c852..659bd8569759d 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php +++ b/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\Doctrine\Validator; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\Persistence\ManagerRegistry; use Symfony\Component\Validator\ObjectInitializerInterface; @@ -24,10 +23,7 @@ class DoctrineInitializer implements ObjectInitializerInterface { protected $registry; - /** - * @param ManagerRegistry|LegacyManagerRegistry $registry - */ - public function __construct($registry) + public function __construct(ManagerRegistry $registry) { $this->registry = $registry; } diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 57f31044f1cd2..2274936c3a9c2 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -18,7 +18,7 @@ "require": { "php": "^7.1.3", "doctrine/event-manager": "~1.0", - "doctrine/persistence": "~1.0", + "doctrine/persistence": "^1.3", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^1.1" diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php index 53271e1808ce4..298127c3e7ad5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php @@ -11,7 +11,6 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\Persistence\ManagerRegistry; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; @@ -83,7 +82,7 @@ public static function getSubscribedServices() 'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class, 'templating' => '?'.EngineInterface::class, 'twig' => '?'.Environment::class, - 'doctrine' => '?'.(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class), + 'doctrine' => '?'.ManagerRegistry::class, 'form.factory' => '?'.FormFactoryInterface::class, 'security.token_storage' => '?'.TokenStorageInterface::class, 'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class, diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php index 425d711b8bc5a..c7ef9b8f2c3bc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php @@ -11,7 +11,6 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\Persistence\ManagerRegistry; use Fig\Link\GenericLinkProvider; use Fig\Link\Link; @@ -337,7 +336,7 @@ protected function createFormBuilder($data = null, array $options = []): FormBui /** * Shortcut to return the Doctrine Registry service. * - * @return ManagerRegistry|LegacyManagerRegistry + * @return ManagerRegistry * * @throws \LogicException If DoctrineBundle is not available * diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 568037090b928..5c8b88ec6a97a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; use Psr\Container\ContainerInterface; -use Doctrine\Persistence\ManagerRegistry; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag; @@ -40,7 +39,7 @@ public function testSubscribedServices() 'security.authorization_checker' => '?Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface', 'templating' => '?Symfony\\Component\\Templating\\EngineInterface', 'twig' => '?Twig\\Environment', - 'doctrine' => interface_exists(ManagerRegistry::class) ? '?'.ManagerRegistry::class : '?Doctrine\\Common\\Persistence\\ManagerRegistry', + 'doctrine' => '?Doctrine\\Persistence\\ManagerRegistry', 'form.factory' => '?Symfony\\Component\\Form\\FormFactoryInterface', 'parameter_bag' => '?Symfony\\Component\\DependencyInjection\\ParameterBag\\ContainerBagInterface', 'message_bus' => '?Symfony\\Component\\Messenger\\MessageBusInterface', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php index d65be3e58f852..f4d0153275aef 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php @@ -11,7 +11,6 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; -use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; use Doctrine\Persistence\ManagerRegistry; use Fig\Link\Link; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; @@ -524,7 +523,7 @@ public function testCreateFormBuilder() public function testGetDoctrine() { - $doctrine = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock(); + $doctrine = $this->getMockBuilder(ManagerRegistry::class)->getMock(); $container = new Container(); $container->set('doctrine', $doctrine); diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index b554b2be63eab..a05c47a2a7238 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -64,6 +64,7 @@ "twig/twig": "~1.41|~2.10" }, "conflict": { + "doctrine/persistence": "<1.3", "phpdocumentor/reflection-docblock": "<3.0", "phpdocumentor/type-resolver": "<0.2.1", "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy