From 58419c5b37a2be29c1fdf34eff458b8fbc23b22c Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Sun, 9 Dec 2018 11:10:53 +0000 Subject: [PATCH 1/9] Update branch-alias to 1.11.x-dev --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 86e04d70f..dcc066c62 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.9.x-dev" + "dev-master": "1.11.x-dev" } } } From fe2d0dc803cc18cd02177251b24bd9ffd2882bfe Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Sun, 9 Dec 2018 13:27:31 +0000 Subject: [PATCH 2/9] Drop support for old PHP and Symfony versions --- .travis.yml | 21 +++++++++++---------- composer.json | 29 +++++++++++++++-------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0ca7444ea..ed6158991 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,9 @@ cache: - $HOME/.composer/cache php: - - 5.5 - - 5.6 - - 7.0 - 7.1 - 7.2 + - 7.3 - nightly env: @@ -31,34 +29,37 @@ script: jobs: include: - - php: 5.5 + # Tests the lowest set of dependencies + - php: 7.1 env: deps=low SYMFONY_DEPRECATIONS_HELPER=weak install: - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update -n --prefer-lowest --prefer-stable --prefer-dist - - php: 5.6 - env: SYMFONY_VERSION="2.8.*" - - - php: 7.0 - env: SYMFONY_VERSION="3.2.*" + # Test against latest Symfony 3.4 stable + - php: 7.1 + env: SYMFONY_VERSION="3.4.*" + # Test against latest Symfony 3.4 dev version - php: 7.1 - env: stability=RC SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="3.4.*" + env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="3.4.*" install: - travis_retry composer update -n --prefer-dist + # Test against latest Symfony 4.1 dev version - php: 7.1 env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="4.1.*" install: - composer require --dev "symfony/messenger:4.1.*" --no-update - travis_retry composer update -n --prefer-dist + # Test against latest Symfony 4.2 dev version - php: 7.1 env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="4.2.*" install: - composer require --dev "symfony/messenger:4.2.*" --no-update - travis_retry composer update -n --prefer-dist + # Test alpha packages - php: 7.2 env: stability=alpha install: diff --git a/composer.json b/composer.json index dcc066c62..a8c725014 100644 --- a/composer.json +++ b/composer.json @@ -24,28 +24,29 @@ } ], "require": { - "php": "^5.5.9|^7.0", - "symfony/framework-bundle": "^2.7.22|~3.0|~4.0", - "symfony/console": "~2.7|~3.0|~4.0", - "symfony/dependency-injection": "~2.7|~3.0|~4.0", + "php": "^7.1", + "symfony/framework-bundle": "^3.4|^4.1", + "symfony/config": "^3.4|^4.1", + "symfony/console": "^3.4|^4.1", + "symfony/dependency-injection": "^3.4|^4.1", "doctrine/dbal": "^2.5.12", "jdorn/sql-formatter": "^1.2.16", - "symfony/doctrine-bridge": "~2.7|~3.0|~4.0", + "symfony/doctrine-bridge": "^3.4|^4.1", "doctrine/doctrine-cache-bundle": "~1.2" }, "require-dev": { - "doctrine/orm": "~2.4", - "symfony/yaml": "~2.7|~3.0|~4.0", - "symfony/validator": "~2.7|~3.0|~4.0", - "symfony/property-info": "~2.8|~3.0|~4.0", - "symfony/phpunit-bridge": "~2.7|~3.0|~4.0", - "twig/twig": "~1.26|~2.0", + "doctrine/orm": "^2.6", + "symfony/yaml": "^3.4|^4.1", + "symfony/validator": "^3.4|^4.1", + "symfony/property-info": "^3.4|^4.1", + "symfony/phpunit-bridge": "^4.2", + "twig/twig": "^1.26|^2.0", "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^4.8.36|^5.7|^6.4", - "symfony/web-profiler-bundle": "~2.7|~3.0|~4.0" + "phpunit/phpunit": "7.0", + "symfony/web-profiler-bundle": "^3.4|^4.1" }, "conflict": { - "symfony/http-foundation": "<2.6" + "doctrine/orm": "<2.6" }, "suggest": { "symfony/web-profiler-bundle": "To use the data collector.", From 0a5fd39b6f1bbb568e0fd612d67c741f55aa750a Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Sun, 9 Dec 2018 14:58:14 +0000 Subject: [PATCH 3/9] Stop using DelegateCommand --- .../Proxy/CollectionRegionDoctrineCommand.php | 25 ++++++++----------- .../EntityRegionCacheDoctrineCommand.php | 24 ++++++++---------- .../Proxy/QueryRegionCacheDoctrineCommand.php | 24 ++++++++---------- 3 files changed, 31 insertions(+), 42 deletions(-) diff --git a/Command/Proxy/CollectionRegionDoctrineCommand.php b/Command/Proxy/CollectionRegionDoctrineCommand.php index 35b08aa90..1f5cba952 100644 --- a/Command/Proxy/CollectionRegionDoctrineCommand.php +++ b/Command/Proxy/CollectionRegionDoctrineCommand.php @@ -3,11 +3,14 @@ namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy; use Doctrine\ORM\Tools\Console\Command\ClearCache\CollectionRegionCommand; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to clear a collection cache region. */ -class CollectionRegionDoctrineCommand extends DelegateCommand +class CollectionRegionDoctrineCommand extends CollectionRegionCommand { /** * {@inheritDoc} @@ -16,22 +19,16 @@ protected function configure() { parent::configure(); - $this->setName('doctrine:cache:clear-collection-region'); + $this + ->setName('doctrine:cache:clear-collection-region') + ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command'); } - /** - * {@inheritDoc} - */ - protected function createCommand() + protected function execute(InputInterface $input, OutputInterface $output) { - return new CollectionRegionCommand(); - } + DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection')); - /** - * {@inheritDoc} - */ - protected function getMinimalVersion() - { - return '2.5.0-DEV'; + return parent::execute($input, $output); } + } diff --git a/Command/Proxy/EntityRegionCacheDoctrineCommand.php b/Command/Proxy/EntityRegionCacheDoctrineCommand.php index 0969c01e7..4b2d40d56 100644 --- a/Command/Proxy/EntityRegionCacheDoctrineCommand.php +++ b/Command/Proxy/EntityRegionCacheDoctrineCommand.php @@ -3,11 +3,14 @@ namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy; use Doctrine\ORM\Tools\Console\Command\ClearCache\EntityRegionCommand; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to clear a entity cache region. */ -class EntityRegionCacheDoctrineCommand extends DelegateCommand +class EntityRegionCacheDoctrineCommand extends EntityRegionCommand { /** * {@inheritDoc} @@ -16,22 +19,15 @@ protected function configure() { parent::configure(); - $this->setName('doctrine:cache:clear-entity-region'); + $this + ->setName('doctrine:cache:clear-entity-region') + ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command'); } - /** - * {@inheritDoc} - */ - protected function createCommand() + protected function execute(InputInterface $input, OutputInterface $output) { - return new EntityRegionCommand(); - } + DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection')); - /** - * {@inheritDoc} - */ - protected function getMinimalVersion() - { - return '2.5.0-DEV'; + return parent::execute($input, $output); } } diff --git a/Command/Proxy/QueryRegionCacheDoctrineCommand.php b/Command/Proxy/QueryRegionCacheDoctrineCommand.php index 7200646af..084841b90 100644 --- a/Command/Proxy/QueryRegionCacheDoctrineCommand.php +++ b/Command/Proxy/QueryRegionCacheDoctrineCommand.php @@ -3,11 +3,14 @@ namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy; use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryRegionCommand; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; /** * Command to clear a query cache region. */ -class QueryRegionCacheDoctrineCommand extends DelegateCommand +class QueryRegionCacheDoctrineCommand extends QueryRegionCommand { /** * {@inheritDoc} @@ -16,22 +19,15 @@ protected function configure() { parent::configure(); - $this->setName('doctrine:cache:clear-query-region'); + $this + ->setName('doctrine:cache:clear-query-region') + ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command'); } - /** - * {@inheritDoc} - */ - protected function createCommand() + protected function execute(InputInterface $input, OutputInterface $output) { - return new QueryRegionCommand(); - } + DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection')); - /** - * {@inheritDoc} - */ - protected function getMinimalVersion() - { - return '2.5.0-DEV'; + return parent::execute($input, $output); } } From 224cfb61e88a2f9b8e3f0386c6687dbfba5d96fb Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Sun, 9 Dec 2018 15:01:31 +0000 Subject: [PATCH 4/9] Drop compatibility layer for older ORM versions --- DataCollector/DoctrineDataCollector.php | 4 -- DependencyInjection/DoctrineExtension.php | 42 ++++----------- .../AbstractDoctrineExtensionTest.php | 52 ++----------------- .../DoctrineExtensionTest.php | 16 ++---- 4 files changed, 16 insertions(+), 98 deletions(-) diff --git a/DataCollector/DoctrineDataCollector.php b/DataCollector/DoctrineDataCollector.php index b1e2af663..0f6019d20 100644 --- a/DataCollector/DoctrineDataCollector.php +++ b/DataCollector/DoctrineDataCollector.php @@ -84,10 +84,6 @@ public function collect(Request $request, Response $response, Exception $excepti $errors[$name][$class->getName()] = $classErrors; } - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - continue; - } - /** @var Configuration $emConfig */ $emConfig = $em->getConfiguration(); $slcEnabled = $emConfig->isSecondLevelCacheEnabled(); diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php index ba76ef9c4..cccd037b2 100644 --- a/DependencyInjection/DoctrineExtension.php +++ b/DependencyInjection/DoctrineExtension.php @@ -378,13 +378,7 @@ protected function ormLoad(array $config, ContainerBuilder $container) ]); } - // BC: ResolveTargetEntityListener implements the subscriber interface since - // v2.5.0-beta1 (Commit 437f812) - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $def->addTag('doctrine.event_listener', ['event' => 'loadClassMetadata']); - } else { - $def->addTag('doctrine.event_subscriber'); - } + $def->addTag('doctrine.event_subscriber'); } // if is for Symfony 3.2 and lower compat @@ -447,30 +441,18 @@ protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $ 'setAutoGenerateProxyClasses' => '%doctrine.orm.auto_generate_proxy_classes%', 'setClassMetadataFactoryName' => $entityManager['class_metadata_factory_name'], 'setDefaultRepositoryClassName' => $entityManager['default_repository_class'], + 'setNamingStrategy' => new Reference($entityManager['naming_strategy']), + 'setQuoteStrategy' => new Reference($entityManager['quote_strategy']), + 'setEntityListenerResolver' => new Reference(sprintf('doctrine.orm.%s_entity_listener_resolver', $entityManager['name'])), ]; - // check for version to keep BC - if (version_compare(Version::VERSION, '2.3.0-DEV') >= 0) { - $methods = array_merge($methods, [ - 'setNamingStrategy' => new Reference($entityManager['naming_strategy']), - 'setQuoteStrategy' => new Reference($entityManager['quote_strategy']), - ]); - } - - if (version_compare(Version::VERSION, '2.4.0-DEV') >= 0) { - $methods = array_merge($methods, [ - 'setEntityListenerResolver' => new Reference(sprintf('doctrine.orm.%s_entity_listener_resolver', $entityManager['name'])), - ]); - } - if (version_compare(Version::VERSION, '2.5.0-DEV') >= 0) { - $listenerId = sprintf('doctrine.orm.%s_listeners.attach_entity_listeners', $entityManager['name']); - $listenerDef = $container->setDefinition($listenerId, new Definition('%doctrine.orm.listeners.attach_entity_listeners.class%')); - $listenerTagParams = ['event' => 'loadClassMetadata']; - if (isset($entityManager['connection'])) { - $listenerTagParams['connection'] = $entityManager['connection']; - } - $listenerDef->addTag('doctrine.event_listener', $listenerTagParams); + $listenerId = sprintf('doctrine.orm.%s_listeners.attach_entity_listeners', $entityManager['name']); + $listenerDef = $container->setDefinition($listenerId, new Definition('%doctrine.orm.listeners.attach_entity_listeners.class%')); + $listenerTagParams = ['event' => 'loadClassMetadata']; + if (isset($entityManager['connection'])) { + $listenerTagParams['connection'] = $entityManager['connection']; } + $listenerDef->addTag('doctrine.event_listener', $listenerTagParams); if (isset($entityManager['second_level_cache'])) { $this->loadOrmSecondLevelCache($entityManager, $ormConfigDef, $container); @@ -640,10 +622,6 @@ protected function loadOrmEntityManagerMappingInformation(array $entityManager, */ protected function loadOrmSecondLevelCache(array $entityManager, Definition $ormConfigDef, ContainerBuilder $container) { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - throw new \InvalidArgumentException('Second-level cache requires doctrine-orm 2.5.0 or newer'); - } - $driverId = null; $enabled = $entityManager['second_level_cache']['enabled']; diff --git a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index bf1fd58a1..f9412c1c8 100644 --- a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -567,9 +567,6 @@ public function testSetCustomFunctions() public function testSetNamingStrategy() { - if (version_compare(Version::VERSION, '2.3.0-DEV') < 0) { - $this->markTestSkipped('Naming Strategies are not available'); - } $container = $this->loadContainer('orm_namingstrategy'); $def1 = $container->getDefinition('doctrine.orm.em1_configuration'); @@ -581,9 +578,6 @@ public function testSetNamingStrategy() public function testSetQuoteStrategy() { - if (version_compare(Version::VERSION, '2.3.0-DEV') < 0) { - $this->markTestSkipped('Quote Strategies are not available'); - } $container = $this->loadContainer('orm_quotestrategy'); $def1 = $container->getDefinition('doctrine.orm.em1_configuration'); @@ -595,10 +589,6 @@ public function testSetQuoteStrategy() public function testSecondLevelCache() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped('Second-level cache requires doctrine-orm 2.5.0 or newer'); - } - $container = $this->loadContainer('orm_second_level_cache'); $this->assertTrue($container->has('doctrine.orm.default_configuration')); @@ -698,19 +688,11 @@ public function testResolveTargetEntity() $definition = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity'); $this->assertDICDefinitionMethodCallOnce($definition, 'addResolveTargetEntity', ['Symfony\Component\Security\Core\User\UserInterface', 'MyUserClass', []]); - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->assertEquals(['doctrine.event_listener' => [['event' => 'loadClassMetadata']]], $definition->getTags()); - } else { - $this->assertEquals(['doctrine.event_subscriber' => [[]]], $definition->getTags()); - } + $this->assertEquals(['doctrine.event_subscriber' => [[]]], $definition->getTags()); } public function testAttachEntityListeners() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped('This test requires ORM 2.5-dev.'); - } - $container = $this->loadContainer('orm_attach_entity_listener'); $definition = $container->getDefinition('doctrine.orm.default_listeners.attach_entity_listeners'); @@ -817,14 +799,10 @@ public function testEntityListenerResolver() $container = $this->loadContainer('orm_entity_listener_resolver', ['YamlBundle'], new EntityListenerPass()); $definition = $container->getDefinition('doctrine.orm.em1_configuration'); - if (version_compare(Version::VERSION, '2.4.0-DEV') >= 0) { - $this->assertDICDefinitionMethodCallOnce($definition, 'setEntityListenerResolver', [new Reference('doctrine.orm.em1_entity_listener_resolver')]); - } + $this->assertDICDefinitionMethodCallOnce($definition, 'setEntityListenerResolver', [new Reference('doctrine.orm.em1_entity_listener_resolver')]); $definition = $container->getDefinition('doctrine.orm.em2_configuration'); - if (version_compare(Version::VERSION, '2.4.0-DEV') >= 0) { - $this->assertDICDefinitionMethodCallOnce($definition, 'setEntityListenerResolver', [new Reference('doctrine.orm.em2_entity_listener_resolver')]); - } + $this->assertDICDefinitionMethodCallOnce($definition, 'setEntityListenerResolver', [new Reference('doctrine.orm.em2_entity_listener_resolver')]); $listener = $container->getDefinition('doctrine.orm.em1_entity_listener_resolver'); $this->assertDICDefinitionMethodCallOnce($listener, 'register', [new Reference('entity_listener1')]); @@ -835,10 +813,6 @@ public function testEntityListenerResolver() public function testAttachEntityListenerTag() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped('Attaching entity listeners by tag requires doctrine-orm 2.5.0 or newer'); - } - $container = $this->getContainer([]); $loader = new DoctrineExtension(); $container->registerExtension($loader); @@ -863,10 +837,6 @@ public function testAttachEntityListenerTag() public function testAttachEntityListenersTwoConnections() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped('Attaching entity listeners by tag requires doctrine-orm 2.5.0 or newer'); - } - $container = $this->getContainer(['YamlBundle']); $loader = new DoctrineExtension(); $container->registerExtension($loader); @@ -887,10 +857,6 @@ public function testAttachEntityListenersTwoConnections() public function testAttachLazyEntityListener() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped('Attaching entity listeners by tag requires doctrine-orm 2.5.0 or newer'); - } - $container = $this->getContainer([]); $loader = new DoctrineExtension(); $container->registerExtension($loader); @@ -913,10 +879,6 @@ public function testAttachLazyEntityListener() */ public function testLazyEntityListenerResolverWithoutCorrectInterface() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped('Attaching entity listeners by tag requires doctrine-orm 2.5.0 or newer'); - } - $container = $this->getContainer([]); $loader = new DoctrineExtension(); $container->registerExtension($loader); @@ -929,10 +891,6 @@ public function testLazyEntityListenerResolverWithoutCorrectInterface() public function testPrivateLazyEntityListener() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped('Attaching entity listeners by tag requires doctrine-orm 2.5.0 or newer'); - } - $container = $this->getContainer([]); $loader = new DoctrineExtension(); $container->registerExtension($loader); @@ -951,10 +909,6 @@ public function testPrivateLazyEntityListener() */ public function testAbstractLazyEntityListener() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped('Attaching entity listeners by tag requires doctrine-orm 2.5.0 or newer'); - } - $container = $this->getContainer([]); $loader = new DoctrineExtension(); $container->registerExtension($loader); diff --git a/Tests/DependencyInjection/DoctrineExtensionTest.php b/Tests/DependencyInjection/DoctrineExtensionTest.php index 54312c952..6874c7aa7 100644 --- a/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -326,13 +326,9 @@ public function testDependencyInjectionConfigurationDefaults() $this->assertEquals('doctrine.orm.default_query_cache', (string) $calls[2][1][0]); $this->assertEquals('doctrine.orm.default_result_cache', (string) $calls[3][1][0]); - if (version_compare(Version::VERSION, '2.3.0-DEV') >= 0) { - $this->assertEquals('doctrine.orm.naming_strategy.default', (string) $calls[10][1][0]); - $this->assertEquals('doctrine.orm.quote_strategy.default', (string) $calls[11][1][0]); - } - if (version_compare(Version::VERSION, '2.4.0-DEV') >= 0) { - $this->assertEquals('doctrine.orm.default_entity_listener_resolver', (string) $calls[12][1][0]); - } + $this->assertEquals('doctrine.orm.naming_strategy.default', (string) $calls[10][1][0]); + $this->assertEquals('doctrine.orm.quote_strategy.default', (string) $calls[11][1][0]); + $this->assertEquals('doctrine.orm.default_entity_listener_resolver', (string) $calls[12][1][0]); $definition = $container->getDefinition((string) $container->getAlias('doctrine.orm.default_metadata_cache')); $this->assertEquals('%doctrine_cache.array.class%', $definition->getClass()); @@ -415,9 +411,6 @@ public function testSingleEntityManagerWithDefaultConfiguration() public function testSingleEntityManagerWithDefaultSecondLevelCacheConfiguration() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped(sprintf('Second Level cache not supported by this version of the ORM : %s', Version::VERSION)); - } $container = $this->getContainer(); $extension = new DoctrineExtension(); @@ -448,9 +441,6 @@ public function testSingleEntityManagerWithDefaultSecondLevelCacheConfiguration( public function testSingleEntityManagerWithCustomSecondLevelCacheConfiguration() { - if (version_compare(Version::VERSION, '2.5.0-DEV') < 0) { - $this->markTestSkipped(sprintf('Second Level cache not supported by this version of the ORM : %s', Version::VERSION)); - } $container = $this->getContainer(); $extension = new DoctrineExtension(); From 6b25ea4a88b10660c492724434824b945f6eedf7 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Sun, 9 Dec 2018 15:15:28 +0000 Subject: [PATCH 5/9] Drop BC layers for old Symfony versions --- DataCollector/DoctrineDataCollector.php | 13 ++-- .../ServiceRepositoryCompilerPass.php | 9 --- DependencyInjection/DoctrineExtension.php | 65 ++++--------------- DoctrineBundle.php | 4 +- Repository/ContainerRepositoryFactory.php | 7 +- Resources/config/orm.xml | 6 +- Tests/ConnectionFactoryTest.php | 3 +- Tests/ContainerTest.php | 16 ++--- .../DoctrineDataCollectorTest.php | 8 +-- .../AbstractDoctrineExtensionTest.php | 37 ++--------- .../DoctrineExtensionTest.php | 34 ++-------- ...ntainerAwareEntityListenerResolverTest.php | 5 +- .../DisconnectedMetadataFactoryTest.php | 3 +- Tests/ProfilerTest.php | 4 +- .../ContainerRepositoryFactoryTest.php | 31 +-------- Tests/ServiceRepositoryTest.php | 27 ++------ Tests/TestCase.php | 5 +- Twig/DoctrineExtension.php | 3 +- 18 files changed, 61 insertions(+), 219 deletions(-) diff --git a/DataCollector/DoctrineDataCollector.php b/DataCollector/DoctrineDataCollector.php index 0f6019d20..b8cb56d9e 100644 --- a/DataCollector/DoctrineDataCollector.php +++ b/DataCollector/DoctrineDataCollector.php @@ -136,14 +136,11 @@ public function collect(Request $request, Response $response, Exception $excepti } } - // HttpKernel < 3.2 compatibility layer - if (method_exists($this, 'cloneVar')) { - // Might be good idea to replicate this block in doctrine bridge so we can drop this from here after some time. - // This code is compatible with such change, because cloneVar is supposed to check if input is already cloned. - foreach ($this->data['queries'] as &$queries) { - foreach ($queries as &$query) { - $query['params'] = $this->cloneVar($query['params']); - } + // Might be good idea to replicate this block in doctrine bridge so we can drop this from here after some time. + // This code is compatible with such change, because cloneVar is supposed to check if input is already cloned. + foreach ($this->data['queries'] as &$queries) { + foreach ($queries as &$query) { + $query['params'] = $this->cloneVar($query['params']); } } diff --git a/DependencyInjection/Compiler/ServiceRepositoryCompilerPass.php b/DependencyInjection/Compiler/ServiceRepositoryCompilerPass.php index 7ccafb74e..50d838cc0 100644 --- a/DependencyInjection/Compiler/ServiceRepositoryCompilerPass.php +++ b/DependencyInjection/Compiler/ServiceRepositoryCompilerPass.php @@ -23,15 +23,6 @@ public function process(ContainerBuilder $container) $repoServiceIds = array_keys($container->findTaggedServiceIds(self::REPOSITORY_SERVICE_TAG)); - // Symfony 3.2 and lower sanity check - if (! class_exists(ServiceLocatorTagPass::class)) { - if (! empty($repoServiceIds)) { - throw new RuntimeException(sprintf('The "%s" tag can only be used with Symfony 3.3 or higher. Remove the tag from the following services (%s) or upgrade to Symfony 3.3 or higher.', self::REPOSITORY_SERVICE_TAG, implode(', ', $repoServiceIds))); - } - - return; - } - $repoReferences = array_map(static function ($id) { return new Reference($id); }, $repoServiceIds); diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php index cccd037b2..a4c071c49 100644 --- a/DependencyInjection/DoctrineExtension.php +++ b/DependencyInjection/DoctrineExtension.php @@ -22,9 +22,9 @@ use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\Form\AbstractType; use Symfony\Component\Messenger\MessageBusInterface; +use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface; use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface; /** @@ -65,7 +65,7 @@ public function load(array $configs, ContainerBuilder $container) throw new LogicException('Configuring the ORM layer requires to configure the DBAL layer as well.'); } - if (! class_exists('Doctrine\ORM\Version')) { + if (! class_exists(Version::class)) { throw new LogicException('To configure the ORM layer, you must first install the doctrine/orm package.'); } @@ -123,10 +123,7 @@ protected function dbalLoad(array $config, ContainerBuilder $container) */ protected function loadDbalConnection($name, array $connection, ContainerBuilder $container) { - // configuration - $definitionClassname = $this->getDefinitionClassname(); - - $configuration = $container->setDefinition(sprintf('doctrine.dbal.%s_connection.configuration', $name), new $definitionClassname('doctrine.dbal.connection.configuration')); + $configuration = $container->setDefinition(sprintf('doctrine.dbal.%s_connection.configuration', $name), new ChildDefinition('doctrine.dbal.connection.configuration')); $logger = null; if ($connection['logging']) { $logger = new Reference('doctrine.dbal.logger'); @@ -134,12 +131,12 @@ protected function loadDbalConnection($name, array $connection, ContainerBuilder unset($connection['logging']); if ($connection['profiling']) { $profilingLoggerId = 'doctrine.dbal.logger.profiling.' . $name; - $container->setDefinition($profilingLoggerId, new $definitionClassname('doctrine.dbal.logger.profiling')); + $container->setDefinition($profilingLoggerId, new ChildDefinition('doctrine.dbal.logger.profiling')); $profilingLogger = new Reference($profilingLoggerId); $container->getDefinition('data_collector.doctrine')->addMethodCall('addLogger', [$name, $profilingLogger]); if ($logger !== null) { - $chainLogger = new $definitionClassname('doctrine.dbal.logger.chain'); + $chainLogger = new ChildDefinition('doctrine.dbal.logger.chain'); $chainLogger->addMethodCall('addLogger', [$profilingLogger]); $loggerId = 'doctrine.dbal.logger.chain.' . $name; @@ -168,13 +165,13 @@ protected function loadDbalConnection($name, array $connection, ContainerBuilder } // event manager - $container->setDefinition(sprintf('doctrine.dbal.%s_connection.event_manager', $name), new $definitionClassname('doctrine.dbal.connection.event_manager')); + $container->setDefinition(sprintf('doctrine.dbal.%s_connection.event_manager', $name), new ChildDefinition('doctrine.dbal.connection.event_manager')); // connection $options = $this->getConnectionOptions($connection); $def = $container - ->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), new $definitionClassname('doctrine.dbal.connection')) + ->setDefinition(sprintf('doctrine.dbal.%s_connection', $name), new ChildDefinition('doctrine.dbal.connection')) ->setPublic(true) ->setArguments([ $options, @@ -328,10 +325,6 @@ protected function ormLoad(array $config, ContainerBuilder $container) $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('orm.xml'); - if (class_exists(AbstractType::class) && method_exists(DoctrineType::class, 'reset')) { - $container->getDefinition('form.type.entity')->addTag('kernel.reset', ['method' => 'reset']); - } - $entityManagers = []; foreach (array_keys($config['entity_managers']) as $name) { $entityManagers[$name] = sprintf('doctrine.orm.%s_entity_manager', $name); @@ -354,17 +347,10 @@ protected function ormLoad(array $config, ContainerBuilder $container) $config['entity_managers'] = $this->fixManagersAutoMappings($config['entity_managers'], $container->getParameter('kernel.bundles')); - $loadPropertyInfoExtractor = interface_exists('Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface') - && class_exists('Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor'); - foreach ($config['entity_managers'] as $name => $entityManager) { $entityManager['name'] = $name; $this->loadOrmEntityManager($entityManager, $container); - if (! $loadPropertyInfoExtractor) { - continue; - } - $this->loadPropertyInfoExtractor($name, $container); } @@ -381,32 +367,14 @@ protected function ormLoad(array $config, ContainerBuilder $container) $def->addTag('doctrine.event_subscriber'); } - // if is for Symfony 3.2 and lower compat - if (method_exists($container, 'registerForAutoconfiguration')) { - $container->registerForAutoconfiguration(ServiceEntityRepositoryInterface::class) - ->addTag(ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG); - } + $container->registerForAutoconfiguration(ServiceEntityRepositoryInterface::class) + ->addTag(ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG); // If the Messenger component is installed and the doctrine transaction middleware is available, wire it: if (interface_exists(MessageBusInterface::class) && class_exists(DoctrineTransactionMiddleware::class)) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('messenger.xml'); } - - /* - * Compatibility for Symfony 3.2 and lower: gives the service a default argument. - * When DoctrineBundle requires 3.3 or higher, this can be moved to an anonymous - * service in orm.xml. - * - * This is replaced with a true locator by ServiceRepositoryCompilerPass. - * This makes that pass technically optional (good for tests). - */ - if (! class_exists(ServiceLocator::class)) { - return; - } - - $container->getDefinition('doctrine.orm.container_repository_factory') - ->replaceArgument(0, (new Definition(ServiceLocator::class))->setArgument(0, [])); } /** @@ -417,8 +385,7 @@ protected function ormLoad(array $config, ContainerBuilder $container) */ protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $container) { - $definitionClassname = $this->getDefinitionClassname(); - $ormConfigDef = $container->setDefinition(sprintf('doctrine.orm.%s_configuration', $entityManager['name']), new $definitionClassname('doctrine.orm.configuration')); + $ormConfigDef = $container->setDefinition(sprintf('doctrine.orm.%s_configuration', $entityManager['name']), new ChildDefinition('doctrine.orm.configuration')); $this->loadOrmEntityManagerMappingInformation($entityManager, $ormConfigDef, $container); $this->loadOrmCacheDrivers($entityManager, $container); @@ -498,7 +465,7 @@ protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $ $managerConfiguratorName = sprintf('doctrine.orm.%s_manager_configurator', $entityManager['name']); $container - ->setDefinition($managerConfiguratorName, new $definitionClassname('doctrine.orm.manager_configurator.abstract')) + ->setDefinition($managerConfiguratorName, new ChildDefinition('doctrine.orm.manager_configurator.abstract')) ->replaceArgument(0, $enabledFilters) ->replaceArgument(1, $filtersParameters); @@ -507,7 +474,7 @@ protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $ } $container - ->setDefinition(sprintf('doctrine.orm.%s_entity_manager', $entityManager['name']), new $definitionClassname('doctrine.orm.entity_manager.abstract')) + ->setDefinition(sprintf('doctrine.orm.%s_entity_manager', $entityManager['name']), new ChildDefinition('doctrine.orm.entity_manager.abstract')) ->setPublic(true) ->setArguments([ new Reference(sprintf('doctrine.dbal.%s_connection', $entityManager['connection'])), @@ -827,12 +794,4 @@ public function getConfiguration(array $config, ContainerBuilder $container) { return new Configuration($container->getParameter('kernel.debug')); } - - /** - * @return string - */ - private function getDefinitionClassname() - { - return class_exists(ChildDefinition::class) ? ChildDefinition::class : DefinitionDecorator::class; - } } diff --git a/DoctrineBundle.php b/DoctrineBundle.php index d1f84ae5d..5aeee62cd 100644 --- a/DoctrineBundle.php +++ b/DoctrineBundle.php @@ -105,7 +105,7 @@ public function shutdown() // Clear all entity managers to clear references to entities for GC if ($this->container->hasParameter('doctrine.entity_managers')) { foreach ($this->container->getParameter('doctrine.entity_managers') as $id) { - if (method_exists($this->container, 'initialized') && ! $this->container->initialized($id)) { + if (! $this->container->initialized($id)) { continue; } @@ -119,7 +119,7 @@ public function shutdown() } foreach ($this->container->getParameter('doctrine.connections') as $id) { - if (method_exists($this->container, 'initialized') && ! $this->container->initialized($id)) { + if (! $this->container->initialized($id)) { continue; } diff --git a/Repository/ContainerRepositoryFactory.php b/Repository/ContainerRepositoryFactory.php index cd1b47202..fdb7c38da 100644 --- a/Repository/ContainerRepositoryFactory.php +++ b/Repository/ContainerRepositoryFactory.php @@ -30,7 +30,7 @@ public function __construct(ContainerInterface $container = null) { // When DoctrineBundle requires Symfony 3.3+, this can be removed // and the $container argument can become required. - if ($container === null && class_exists(ServiceLocatorTagPass::class)) { + if ($container === null) { throw new InvalidArgumentException(sprintf('The first argument of %s::__construct() is required on Symfony 3.3 or higher.', self::class)); } @@ -60,11 +60,6 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName // if not in the container but the class/id implements the interface, throw an error if (is_a($customRepositoryName, ServiceEntityRepositoryInterface::class, true)) { - // can be removed when DoctrineBundle requires Symfony 3.3 - if ($this->container === null) { - throw new RuntimeException(sprintf('Support for loading entities from the service container only works for Symfony 3.3 or higher. Upgrade your version of Symfony or make sure your "%s" class does not implement "%s"', $customRepositoryName, ServiceEntityRepositoryInterface::class)); - } - throw new RuntimeException(sprintf('The "%s" entity repository implements "%s", but its service could not be found. Make sure the service exists and is tagged with "%s".', $customRepositoryName, ServiceEntityRepositoryInterface::class, ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG)); } diff --git a/Resources/config/orm.xml b/Resources/config/orm.xml index 78b039c55..0fe60c165 100644 --- a/Resources/config/orm.xml +++ b/Resources/config/orm.xml @@ -103,7 +103,11 @@ - null + + + + + diff --git a/Tests/ConnectionFactoryTest.php b/Tests/ConnectionFactoryTest.php index 04ff6fad9..ea0873911 100644 --- a/Tests/ConnectionFactoryTest.php +++ b/Tests/ConnectionFactoryTest.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Exception\DriverException; +use Doctrine\ORM\Version; use Exception; class ConnectionFactoryTest extends TestCase @@ -14,7 +15,7 @@ protected function setUp() { parent::setUp(); - if (class_exists('Doctrine\\ORM\\Version')) { + if (class_exists(Version::class)) { return; } diff --git a/Tests/ContainerTest.php b/Tests/ContainerTest.php index 07d393db4..58da728ee 100644 --- a/Tests/ContainerTest.php +++ b/Tests/ContainerTest.php @@ -3,6 +3,9 @@ namespace Doctrine\Bundle\DoctrineBundle\Tests; use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Version; +use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor; +use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface; use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface; class ContainerTest extends TestCase @@ -11,7 +14,7 @@ protected function setUp() { parent::setUp(); - if (class_exists('Doctrine\\ORM\\Version')) { + if (class_exists(Version::class)) { return; } @@ -48,14 +51,9 @@ public function testContainer() $this->assertFalse($container->has('doctrine.dbal.default_connection.events.mysqlsessioninit')); - if (interface_exists('Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface') && class_exists('Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor')) { - if (! interface_exists(PropertyInitializableExtractorInterface::class)) { - $this->assertInstanceOf('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory', $container->get('doctrine.orm.default_entity_manager.metadata_factory')); - } - $this->assertInstanceOf('Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor', $container->get('doctrine.orm.default_entity_manager.property_info_extractor')); - } else { - $this->assertFalse($container->has('doctrine.orm.default_entity_manager.metadata_factory')); - $this->assertFalse($container->has('doctrine.orm.default_entity_manager.property_info_extractor')); + if (! interface_exists(PropertyInitializableExtractorInterface::class)) { + $this->assertInstanceOf('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory', $container->get('doctrine.orm.default_entity_manager.metadata_factory')); } + $this->assertInstanceOf('Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor', $container->get('doctrine.orm.default_entity_manager.property_info_extractor')); } } diff --git a/Tests/DataCollector/DoctrineDataCollectorTest.php b/Tests/DataCollector/DoctrineDataCollectorTest.php index c6e121279..2ab96ce13 100644 --- a/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -29,11 +29,9 @@ public function testCollectEntities() ->method('getConfiguration') ->will($this->returnValue($config)); - if (method_exists($config, 'isSecondLevelCacheEnabled')) { - $config->expects($this->once()) - ->method('isSecondLevelCacheEnabled') - ->will($this->returnValue(false)); - } + $config->expects($this->once()) + ->method('isSecondLevelCacheEnabled') + ->will($this->returnValue(false)); $metadatas = [ $this->createEntityMetadata(self::FIRST_ENTITY), diff --git a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index f9412c1c8..71c9bfcaa 100644 --- a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -210,12 +210,7 @@ public function testLoadSimpleSingleConnection() $definition = $container->getDefinition('doctrine.orm.default_entity_manager'); $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); - if (method_exists($definition, 'getFactory')) { - $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); - } else { - $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); - $this->assertEquals('create', $definition->getFactoryMethod()); - } + $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); $this->assertDICConstructorArguments($definition, [ new Reference('doctrine.dbal.default_connection'), @@ -250,12 +245,7 @@ public function testLoadSimpleSingleConnectionWithoutDbName() $definition = $container->getDefinition('doctrine.orm.default_entity_manager'); $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); - if (method_exists($definition, 'getFactory')) { - $factory = $definition->getFactory(); - } else { - $factory[0] = $definition->getFactoryClass(); - $factory[1] = $definition->getFactoryMethod(); - } + $factory = $definition->getFactory(); $this->assertEquals('%doctrine.orm.entity_manager.class%', $factory[0]); $this->assertEquals('create', $factory[1]); @@ -291,12 +281,7 @@ public function testLoadSingleConnection() $definition = $container->getDefinition('doctrine.orm.default_entity_manager'); $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); - if (method_exists($definition, 'setFactory')) { - $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); - } else { - $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); - $this->assertEquals('create', $definition->getFactoryMethod()); - } + $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); $this->assertDICConstructorArguments($definition, [ new Reference('doctrine.dbal.default_connection'), @@ -324,12 +309,7 @@ public function testLoadMultipleConnections() $definition = $container->getDefinition('doctrine.orm.em1_entity_manager'); $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); - if (method_exists($definition, 'getFactory')) { - $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); - } else { - $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); - $this->assertEquals('create', $definition->getFactoryMethod()); - } + $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); $arguments = $definition->getArguments(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]); @@ -348,12 +328,7 @@ public function testLoadMultipleConnections() $definition = $container->getDefinition('doctrine.orm.em2_entity_manager'); $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); - if (method_exists($definition, 'getFactory')) { - $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); - } else { - $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); - $this->assertEquals('create', $definition->getFactoryMethod()); - } + $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); $arguments = $definition->getArguments(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $arguments[0]); @@ -1070,7 +1045,7 @@ private function assertDICDefinitionNoMethodCall(Definition $definition, $method private function compileContainer(ContainerBuilder $container) { - $container->getCompilerPassConfig()->setOptimizationPasses([class_exists(ResolveChildDefinitionsPass::class) ? new ResolveChildDefinitionsPass() : new ResolveDefinitionTemplatesPass()]); + $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveChildDefinitionsPass()]); $container->getCompilerPassConfig()->setRemovingPasses([]); $container->compile(); } diff --git a/Tests/DependencyInjection/DoctrineExtensionTest.php b/Tests/DependencyInjection/DoctrineExtensionTest.php index 6874c7aa7..8b3277800 100644 --- a/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -147,10 +147,6 @@ public function testAutomapping(array $entityManagers) { $extension = new DoctrineExtension(); - if (! method_exists($extension, 'fixManagersAutoMappings')) { - $this->markTestSkipped('Auto mapping with multiple managers available with Symfony ~2.6'); - } - $container = $this->getContainer([ 'YamlBundle', 'XmlBundle', @@ -303,12 +299,7 @@ public function testDependencyInjectionConfigurationDefaults() $definition = $container->getDefinition('doctrine.orm.default_entity_manager'); $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); - if (method_exists($definition, 'getFactory')) { - $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); - } else { - $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); - $this->assertEquals('create', $definition->getFactoryMethod()); - } + $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); $this->assertEquals(['default' => 'doctrine.orm.default_entity_manager'], $container->getParameter('doctrine.entity_managers'), 'Set of the existing EntityManagers names is incorrect.'); $this->assertEquals('%doctrine.entity_managers%', $container->getDefinition('doctrine')->getArgument(2), 'Set of the existing EntityManagers names is incorrect.'); @@ -396,12 +387,7 @@ public function testSingleEntityManagerWithDefaultConfiguration() $definition = $container->getDefinition('doctrine.orm.default_entity_manager'); $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); - if (method_exists($definition, 'getFactory')) { - $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); - } else { - $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); - $this->assertEquals('create', $definition->getFactoryMethod()); - } + $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); $this->assertDICConstructorArguments($definition, [ new Reference('doctrine.dbal.default_connection'), @@ -423,12 +409,7 @@ public function testSingleEntityManagerWithDefaultSecondLevelCacheConfiguration( $definition = $container->getDefinition('doctrine.orm.default_entity_manager'); $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); - if (method_exists($definition, 'getFactory')) { - $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); - } else { - $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); - $this->assertEquals('create', $definition->getFactoryMethod()); - } + $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); $this->assertDICConstructorArguments($definition, [ new Reference('doctrine.dbal.default_connection'), @@ -459,12 +440,7 @@ public function testSingleEntityManagerWithCustomSecondLevelCacheConfiguration() $definition = $container->getDefinition('doctrine.orm.default_entity_manager'); $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); - if (method_exists($definition, 'getFactory')) { - $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); - } else { - $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); - $this->assertEquals('create', $definition->getFactoryMethod()); - } + $this->assertEquals(['%doctrine.orm.entity_manager.class%', 'create'], $definition->getFactory()); $this->assertDICConstructorArguments($definition, [ new Reference('doctrine.dbal.default_connection'), @@ -819,7 +795,7 @@ private function assertDICDefinitionMethodCallOnce(Definition $definition, $meth private function compileContainer(ContainerBuilder $container) { - $container->getCompilerPassConfig()->setOptimizationPasses([class_exists(ResolveChildDefinitionsPass::class) ? new ResolveChildDefinitionsPass() : new ResolveDefinitionTemplatesPass()]); + $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveChildDefinitionsPass()]); $container->getCompilerPassConfig()->setRemovingPasses([]); $container->compile(); } diff --git a/Tests/Mapping/ContainerAwareEntityListenerResolverTest.php b/Tests/Mapping/ContainerAwareEntityListenerResolverTest.php index cbfad8b00..75983ad12 100644 --- a/Tests/Mapping/ContainerAwareEntityListenerResolverTest.php +++ b/Tests/Mapping/ContainerAwareEntityListenerResolverTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Bundle\DoctrineBundle\Tests\Mapping; use Doctrine\Bundle\DoctrineBundle\Mapping\ContainerAwareEntityListenerResolver; +use Doctrine\ORM\Mapping\EntityListenerResolver; use PHPUnit\Framework\TestCase; use PHPUnit_Framework_MockObject_MockObject; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -17,10 +18,6 @@ class ContainerAwareEntityListenerResolverTest extends TestCase protected function setUp() { - if (! interface_exists('\Doctrine\ORM\Mapping\EntityListenerResolver')) { - $this->markTestSkipped('Entity listeners are not supported in this Doctrine version'); - } - parent::setUp(); $this->container = $this->getMockForAbstractClass('\Symfony\Component\DependencyInjection\ContainerInterface'); diff --git a/Tests/Mapping/DisconnectedMetadataFactoryTest.php b/Tests/Mapping/DisconnectedMetadataFactoryTest.php index a1c18fc70..012d0c488 100644 --- a/Tests/Mapping/DisconnectedMetadataFactoryTest.php +++ b/Tests/Mapping/DisconnectedMetadataFactoryTest.php @@ -6,6 +6,7 @@ use Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory; use Doctrine\Bundle\DoctrineBundle\Tests\TestCase; use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\ORM\Version; class DisconnectedMetadataFactoryTest extends TestCase { @@ -13,7 +14,7 @@ protected function setUp() { parent::setUp(); - if (class_exists('Doctrine\\ORM\\Version')) { + if (class_exists(Version::class)) { return; } diff --git a/Tests/ProfilerTest.php b/Tests/ProfilerTest.php index 158341d2d..acb889c75 100644 --- a/Tests/ProfilerTest.php +++ b/Tests/ProfilerTest.php @@ -73,9 +73,7 @@ public function testRender() // This is only needed for WebProfilerBundle=3.2, remove when support for it is dropped $requestCollector = new RequestDataCollector(); $requestCollector->collect($request, $response); - if (method_exists($requestCollector, 'lateCollect')) { - $requestCollector->lateCollect(); - } + $requestCollector->lateCollect(); $profile->addCollector($requestCollector); $output = $this->twig->render('db.html.twig', [ diff --git a/Tests/Repository/ContainerRepositoryFactoryTest.php b/Tests/Repository/ContainerRepositoryFactoryTest.php index a3a3b47b8..63a44368a 100644 --- a/Tests/Repository/ContainerRepositoryFactoryTest.php +++ b/Tests/Repository/ContainerRepositoryFactoryTest.php @@ -17,10 +17,6 @@ class ContainerRepositoryFactoryTest extends TestCase { public function testGetRepositoryReturnsService() { - if (! interface_exists(ContainerInterface::class)) { - $this->markTestSkipped('Symfony 3.3 is needed for this feature.'); - } - $em = $this->createEntityManager(['Foo\CoolEntity' => 'my_repo']); $repo = new StubRepository($em, new ClassMetadata('')); $container = $this->createContainer(['my_repo' => $repo]); @@ -31,10 +27,6 @@ public function testGetRepositoryReturnsService() public function testGetRepositoryReturnsEntityRepository() { - if (! interface_exists(ContainerInterface::class)) { - $this->markTestSkipped('Symfony 3.3 is needed for this feature.'); - } - $container = $this->createContainer([]); $em = $this->createEntityManager(['Foo\BoringEntity' => null]); @@ -47,10 +39,6 @@ public function testGetRepositoryReturnsEntityRepository() public function testCustomRepositoryIsReturned() { - if (! interface_exists(ContainerInterface::class)) { - $this->markTestSkipped('Symfony 3.3 is needed for this feature.'); - } - $container = $this->createContainer([]); $em = $this->createEntityManager([ 'Foo\CustomNormalRepoEntity' => StubRepository::class, @@ -69,10 +57,6 @@ public function testCustomRepositoryIsReturned() */ public function testServiceRepositoriesMustExtendObjectRepository() { - if (! interface_exists(ContainerInterface::class)) { - $this->markTestSkipped('Symfony 3.3 is needed for this feature.'); - } - $repo = new stdClass(); $container = $this->createContainer(['my_repo' => $repo]); @@ -85,10 +69,6 @@ public function testServiceRepositoriesMustExtendObjectRepository() public function testServiceRepositoriesCanNotExtendsEntityRepository() { - if (! interface_exists(ContainerInterface::class)) { - $this->markTestSkipped('Symfony 3.3 is needed for this feature.'); - } - $repo = $this->getMockBuilder(ObjectRepository::class)->getMock(); $container = $this->createContainer(['my_repo' => $repo]); @@ -108,10 +88,6 @@ public function testServiceRepositoriesCanNotExtendsEntityRepository() */ public function testRepositoryMatchesServiceInterfaceButServiceNotFound() { - if (! interface_exists(ContainerInterface::class)) { - $this->markTestSkipped('Symfony 3.3 is needed for this feature.'); - } - $container = $this->createContainer([]); $em = $this->createEntityManager([ @@ -128,12 +104,7 @@ public function testRepositoryMatchesServiceInterfaceButServiceNotFound() */ public function testCustomRepositoryIsNotAValidClass() { - if (interface_exists(ContainerInterface::class)) { - $container = $this->createContainer([]); - } else { - // Symfony 3.2 and lower support - $container = null; - } + $container = $this->createContainer([]); $em = $this->createEntityManager(['Foo\CoolEntity' => 'not_a_real_class']); diff --git a/Tests/ServiceRepositoryTest.php b/Tests/ServiceRepositoryTest.php index 983c46d64..f39f4d8fa 100644 --- a/Tests/ServiceRepositoryTest.php +++ b/Tests/ServiceRepositoryTest.php @@ -8,6 +8,7 @@ use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; +use Doctrine\ORM\Version; use Fixtures\Bundles\RepositoryServiceBundle\Entity\TestCustomClassRepoEntity; use Fixtures\Bundles\RepositoryServiceBundle\Entity\TestCustomServiceRepoEntity; use Fixtures\Bundles\RepositoryServiceBundle\Entity\TestDefaultRepoEntity; @@ -26,7 +27,7 @@ protected function setUp() { parent::setUp(); - if (class_exists('Doctrine\\ORM\\Version')) { + if (class_exists(Version::class)) { return; } @@ -71,15 +72,8 @@ public function testRepositoryServiceWiring() // create a public alias so we can use it below for testing $container->setAlias('test_alias__' . TestCustomServiceRepoRepository::class, new Alias(TestCustomServiceRepoRepository::class, true)); - // Symfony 2.7 compat - can be moved above later - if (method_exists($def, 'setAutowired')) { - $def->setAutowired(true); - } - - // Symfony 3.3 and higher: autowire definition so it receives the tags - if (class_exists(ServiceLocatorTagPass::class)) { - $def->setAutoconfigured(true); - } + $def->setAutowired(true); + $def->setAutoconfigured(true); $container->addCompilerPass(new ServiceRepositoryCompilerPass()); $container->compile(); @@ -100,19 +94,6 @@ public function testRepositoryServiceWiring() // a smoke test, trying one of the methods $this->assertSame(TestDefaultRepoEntity::class, $genericRepository->getClassName()); - // Symfony 3.2 and lower should work normally in traditional cases (tested above) - // the code below should *not* work (by design) - if (! class_exists(ServiceLocatorTagPass::class)) { - $message = '/Support for loading entities from the service container only works for Symfony 3\.3/'; - if (method_exists($this, 'expectException')) { - $this->expectException(RuntimeException::class); - $this->expectExceptionMessageRegExp($message); - } else { - // PHPUnit 4 compat - $this->setExpectedExceptionRegExp(RuntimeException::class, $message); - } - } - // custom service repository $customServiceRepo = $em->getRepository(TestCustomServiceRepoEntity::class); $this->assertSame($customServiceRepo, $container->get('test_alias__' . TestCustomServiceRepoRepository::class)); diff --git a/Tests/TestCase.php b/Tests/TestCase.php index 5a7c8375c..a2c2ac793 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -5,6 +5,7 @@ use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension; use Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType; use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\ORM\Version; use PHPUnit\Framework\TestCase as BaseTestCase; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass; @@ -17,7 +18,7 @@ class TestCase extends BaseTestCase { protected function setUp() { - if (class_exists('Doctrine\\Common\\Version')) { + if (class_exists(Version::class)) { return; } @@ -70,7 +71,7 @@ public function createYamlBundleTestContainer() $container->setDefinition('my.platform', new Definition('Doctrine\DBAL\Platforms\MySqlPlatform'))->setPublic(true); - $container->getCompilerPassConfig()->setOptimizationPasses([class_exists(ResolveChildDefinitionsPass::class) ? new ResolveChildDefinitionsPass() : new ResolveDefinitionTemplatesPass()]); + $container->getCompilerPassConfig()->setOptimizationPasses([new ResolveChildDefinitionsPass()]); $container->getCompilerPassConfig()->setRemovingPasses([]); // make all Doctrine services public, so we can fetch them in the test $container->getCompilerPassConfig()->addPass(new TestCaseAllPublicCompilerPass()); diff --git a/Twig/DoctrineExtension.php b/Twig/DoctrineExtension.php index 6df74cdbe..7361bc085 100644 --- a/Twig/DoctrineExtension.php +++ b/Twig/DoctrineExtension.php @@ -277,8 +277,7 @@ public static function escapeFunction($parameter) public function replaceQueryParameters($query, $parameters) { if ($parameters instanceof Data) { - // VarDumper < 3.3 compatibility layer - $parameters = method_exists($parameters, 'getValue') ? $parameters->getValue(true) : $parameters->getRawData(); + $parameters = $parameters->getValue(true); } $i = 0; From e709e55f732e68aaa25ab7467f903e955fffb863 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 20 Dec 2018 07:31:25 +0100 Subject: [PATCH 6/9] Reconfigure deprecation helper to not fail builds This configures the deprecation helper to not fail builds on all Symfony versions except the latest stable one. We always expect no deprecations when running against the latest versions of Symfony. --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ed6158991..5f8601054 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,30 +31,30 @@ jobs: include: # Tests the lowest set of dependencies - php: 7.1 - env: deps=low SYMFONY_DEPRECATIONS_HELPER=weak + env: deps=low SYMFONY_DEPRECATIONS_HELPER=999999 install: - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update -n --prefer-lowest --prefer-stable --prefer-dist # Test against latest Symfony 3.4 stable - php: 7.1 - env: SYMFONY_VERSION="3.4.*" + env: SYMFONY_VERSION="3.4.*" SYMFONY_DEPRECATIONS_HELPER=999999 # Test against latest Symfony 3.4 dev version - php: 7.1 - env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="3.4.*" + env: stability=dev SYMFONY_DEPRECATIONS_HELPER=999999 SYMFONY_VERSION="3.4.*" install: - travis_retry composer update -n --prefer-dist # Test against latest Symfony 4.1 dev version - php: 7.1 - env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="4.1.*" + env: stability=dev SYMFONY_DEPRECATIONS_HELPER=999999 SYMFONY_VERSION="4.1.*" install: - composer require --dev "symfony/messenger:4.1.*" --no-update - travis_retry composer update -n --prefer-dist # Test against latest Symfony 4.2 dev version - php: 7.1 - env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="4.2.*" + env: stability=dev SYMFONY_VERSION="4.2.*" install: - composer require --dev "symfony/messenger:4.2.*" --no-update - travis_retry composer update -n --prefer-dist From d1e4017c9065c2fc4a95a6af1887ce06eb2edacc Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 20 Dec 2018 07:36:02 +0100 Subject: [PATCH 7/9] Remove BC layer for old WebProfilerBundle --- Tests/ProfilerTest.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Tests/ProfilerTest.php b/Tests/ProfilerTest.php index acb889c75..b78424663 100644 --- a/Tests/ProfilerTest.php +++ b/Tests/ProfilerTest.php @@ -70,12 +70,6 @@ public function testRender() $profile = new Profile('foo'); - // This is only needed for WebProfilerBundle=3.2, remove when support for it is dropped - $requestCollector = new RequestDataCollector(); - $requestCollector->collect($request, $response); - $requestCollector->lateCollect(); - $profile->addCollector($requestCollector); - $output = $this->twig->render('db.html.twig', [ 'request' => $request, 'token' => 'foo', From f7db368b0e579fb3127678bac3b99837f5d98038 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 20 Dec 2018 07:51:41 +0100 Subject: [PATCH 8/9] Require doctrine/coding-standard directly and fix violations --- .travis.yml | 2 -- Command/Proxy/CollectionRegionDoctrineCommand.php | 1 - DataCollector/DoctrineDataCollector.php | 1 - .../Compiler/ServiceRepositoryCompilerPass.php | 1 - DependencyInjection/DoctrineExtension.php | 12 +++++------- Repository/ContainerRepositoryFactory.php | 1 - Tests/ContainerTest.php | 2 -- .../AbstractDoctrineExtensionTest.php | 2 -- Tests/DependencyInjection/DoctrineExtensionTest.php | 2 -- .../ContainerAwareEntityListenerResolverTest.php | 1 - Tests/ProfilerTest.php | 1 - Tests/ServiceRepositoryTest.php | 2 -- Tests/TestCase.php | 1 - composer.json | 3 ++- 14 files changed, 7 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f8601054..3b1aed27e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,8 +69,6 @@ jobs: - stage: Code Quality env: CODING_STANDARDS php: 7.1 - install: - - travis_retry composer require -n --prefer-dist --dev doctrine/coding-standard:^5.0 script: - ./vendor/bin/phpcs diff --git a/Command/Proxy/CollectionRegionDoctrineCommand.php b/Command/Proxy/CollectionRegionDoctrineCommand.php index 1f5cba952..d12614537 100644 --- a/Command/Proxy/CollectionRegionDoctrineCommand.php +++ b/Command/Proxy/CollectionRegionDoctrineCommand.php @@ -30,5 +30,4 @@ protected function execute(InputInterface $input, OutputInterface $output) return parent::execute($input, $output); } - } diff --git a/DataCollector/DoctrineDataCollector.php b/DataCollector/DoctrineDataCollector.php index b8cb56d9e..6fddfd485 100644 --- a/DataCollector/DoctrineDataCollector.php +++ b/DataCollector/DoctrineDataCollector.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Tools\SchemaValidator; -use Doctrine\ORM\Version; use Exception; use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector as BaseCollector; use Symfony\Component\HttpFoundation\Request; diff --git a/DependencyInjection/Compiler/ServiceRepositoryCompilerPass.php b/DependencyInjection/Compiler/ServiceRepositoryCompilerPass.php index 50d838cc0..988155741 100644 --- a/DependencyInjection/Compiler/ServiceRepositoryCompilerPass.php +++ b/DependencyInjection/Compiler/ServiceRepositoryCompilerPass.php @@ -5,7 +5,6 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Reference; final class ServiceRepositoryCompilerPass implements CompilerPassInterface diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php index a4c071c49..7d494e6d0 100644 --- a/DependencyInjection/DoctrineExtension.php +++ b/DependencyInjection/DoctrineExtension.php @@ -10,7 +10,6 @@ use Doctrine\ORM\Version; use LogicException; use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension; -use Symfony\Bridge\Doctrine\Form\Type\DoctrineType; use Symfony\Bridge\Doctrine\Messenger\DoctrineTransactionMiddleware; use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor; use Symfony\Component\Config\FileLocator; @@ -18,13 +17,10 @@ use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\Form\AbstractType; use Symfony\Component\Messenger\MessageBusInterface; -use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface; use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface; /** @@ -371,10 +367,12 @@ protected function ormLoad(array $config, ContainerBuilder $container) ->addTag(ServiceRepositoryCompilerPass::REPOSITORY_SERVICE_TAG); // If the Messenger component is installed and the doctrine transaction middleware is available, wire it: - if (interface_exists(MessageBusInterface::class) && class_exists(DoctrineTransactionMiddleware::class)) { - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); - $loader->load('messenger.xml'); + if (! interface_exists(MessageBusInterface::class) || ! class_exists(DoctrineTransactionMiddleware::class)) { + return; } + + $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader->load('messenger.xml'); } /** diff --git a/Repository/ContainerRepositoryFactory.php b/Repository/ContainerRepositoryFactory.php index fdb7c38da..ae668e097 100644 --- a/Repository/ContainerRepositoryFactory.php +++ b/Repository/ContainerRepositoryFactory.php @@ -10,7 +10,6 @@ use InvalidArgumentException; use Psr\Container\ContainerInterface; use RuntimeException; -use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; /** * Fetches repositories from the container or falls back to normal creation. diff --git a/Tests/ContainerTest.php b/Tests/ContainerTest.php index 58da728ee..073ecb0c7 100644 --- a/Tests/ContainerTest.php +++ b/Tests/ContainerTest.php @@ -4,8 +4,6 @@ use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Version; -use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor; -use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface; use Symfony\Component\PropertyInfo\PropertyInitializableExtractorInterface; class ContainerTest extends TestCase diff --git a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index 71c9bfcaa..1f24100bd 100644 --- a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -5,12 +5,10 @@ use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\EntityListenerPass; use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension; use Doctrine\ORM\EntityManager; -use Doctrine\ORM\Version; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass; -use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; diff --git a/Tests/DependencyInjection/DoctrineExtensionTest.php b/Tests/DependencyInjection/DoctrineExtensionTest.php index 8b3277800..cd20392d6 100644 --- a/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -10,10 +10,8 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Version; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass; -use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; diff --git a/Tests/Mapping/ContainerAwareEntityListenerResolverTest.php b/Tests/Mapping/ContainerAwareEntityListenerResolverTest.php index 75983ad12..696c77419 100644 --- a/Tests/Mapping/ContainerAwareEntityListenerResolverTest.php +++ b/Tests/Mapping/ContainerAwareEntityListenerResolverTest.php @@ -3,7 +3,6 @@ namespace Doctrine\Bundle\DoctrineBundle\Tests\Mapping; use Doctrine\Bundle\DoctrineBundle\Mapping\ContainerAwareEntityListenerResolver; -use Doctrine\ORM\Mapping\EntityListenerResolver; use PHPUnit\Framework\TestCase; use PHPUnit_Framework_MockObject_MockObject; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/Tests/ProfilerTest.php b/Tests/ProfilerTest.php index b78424663..8391a36f2 100644 --- a/Tests/ProfilerTest.php +++ b/Tests/ProfilerTest.php @@ -14,7 +14,6 @@ use Symfony\Bundle\WebProfilerBundle\Twig\WebProfilerExtension; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; diff --git a/Tests/ServiceRepositoryTest.php b/Tests/ServiceRepositoryTest.php index f39f4d8fa..21754f707 100644 --- a/Tests/ServiceRepositoryTest.php +++ b/Tests/ServiceRepositoryTest.php @@ -15,9 +15,7 @@ use Fixtures\Bundles\RepositoryServiceBundle\Repository\TestCustomClassRepoRepository; use Fixtures\Bundles\RepositoryServiceBundle\Repository\TestCustomServiceRepoRepository; use Fixtures\Bundles\RepositoryServiceBundle\RepositoryServiceBundle; -use RuntimeException; use Symfony\Component\DependencyInjection\Alias; -use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; diff --git a/Tests/TestCase.php b/Tests/TestCase.php index a2c2ac793..09a976f3a 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -9,7 +9,6 @@ use PHPUnit\Framework\TestCase as BaseTestCase; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass; -use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; diff --git a/composer.json b/composer.json index a8c725014..3910633e8 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,8 @@ "twig/twig": "^1.26|^2.0", "php-coveralls/php-coveralls": "^2.1", "phpunit/phpunit": "7.0", - "symfony/web-profiler-bundle": "^3.4|^4.1" + "symfony/web-profiler-bundle": "^3.4|^4.1", + "doctrine/coding-standard": "^5.0" }, "conflict": { "doctrine/orm": "<2.6" From 2279d8abd96bf87e0cdbeb95badc8a64924ddc7b Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 20 Dec 2018 16:34:54 +0100 Subject: [PATCH 9/9] Test dev versions of packages (and allow build to fail) --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3b1aed27e..d0d0e6144 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,6 +66,13 @@ jobs: - composer config minimum-stability alpha - travis_retry composer update -n --prefer-dist + # Test dev level software + - php: nightly + env: stability=dev + install: + - composer config minimum-stability dev + - travis_retry composer update -n --prefer-dist + - stage: Code Quality env: CODING_STANDARDS php: 7.1