diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
index 655687575d..d2ddddf3f2 100644
--- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
+++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
@@ -120,7 +120,11 @@ class SymfonyTestsListenerTrait
$this->state = 0;
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
- AnnotationRegistry::registerLoader('class_exists');
+ if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
+ AnnotationRegistry::registerUniqueLoader('class_exists');
+ } else {
+ AnnotationRegistry::registerLoader('class_exists');
+ }
}
if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) {
diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php
index a265a129e6..5de9467891 100644
--- a/src/Symfony/Bridge/PhpUnit/bootstrap.php
+++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php
@@ -28,7 +28,11 @@ if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Comman
setlocale(LC_ALL, 'C');
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
- AnnotationRegistry::registerLoader('class_exists');
+ if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {
+ AnnotationRegistry::registerUniqueLoader('class_exists');
+ } else {
+ AnnotationRegistry::registerLoader('class_exists');
+ }
}
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 8b21f6c644..e4c3b08d93 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
use Doctrine\Common\Annotations\Reader;
+use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@@ -1087,6 +1088,11 @@ class FrameworkExtension extends Extension
$loader->load('annotations.xml');
+ if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
+ $container->getDefinition('annotations.dummy_registry')
+ ->setMethodCalls(array(array('registerLoader', array('class_exists'))));
+ }
+
if ('none' !== $config['cache']) {
$cacheService = $config['cache'];
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
index 15bf002954..b751fe3a3d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
@@ -10,14 +10,14 @@
required
-
-
-
-
- class_exists
-
-
-
+
+
+
+
+
+
+
+ class_exists