From e5492e2e55d11a296bb2d68d45a3aac3e914df84 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 6 Nov 2020 02:06:52 +0100 Subject: [PATCH] [FrameworkBundle] Configure PHP Attributes without doctrine/annotations. --- .../DependencyInjection/FrameworkExtension.php | 8 ++++---- .../Tests/DependencyInjection/FrameworkExtensionTest.php | 2 +- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index dd5b759879..aabf476d41 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -965,11 +965,11 @@ class FrameworkExtension extends Extension ->replaceArgument(0, $config['default_uri']); } - if ($this->annotationsConfigEnabled) { + if (\PHP_VERSION_ID >= 80000 || $this->annotationsConfigEnabled) { $container->register('routing.loader.annotation', AnnotatedRouteControllerLoader::class) ->setPublic(false) ->addTag('routing.loader', ['priority' => -10]) - ->addArgument(new Reference('annotation_reader')); + ->addArgument(new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE)); $container->register('routing.loader.annotation.directory', AnnotationDirectoryLoader::class) ->setPublic(false) @@ -1564,13 +1564,13 @@ class FrameworkExtension extends Extension $serializerLoaders = []; if (isset($config['enable_annotations']) && $config['enable_annotations']) { - if (!$this->annotationsConfigEnabled) { + if (\PHP_VERSION_ID < 80000 && !$this->annotationsConfigEnabled) { throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.'); } $annotationLoader = new Definition( 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader', - [new Reference('annotation_reader')] + [new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE)] ); $annotationLoader->setPublic(false); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index fdb1d5a601..48ac02ccc1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -1232,7 +1232,7 @@ abstract class FrameworkExtensionTest extends TestCase $projectDir = $container->getParameter('kernel.project_dir'); $configDir = __DIR__.'/Fixtures/TestBundle/Resources/config'; $expectedLoaders = [ - new Definition(AnnotationLoader::class, [new Reference('annotation_reader')]), + new Definition(AnnotationLoader::class, [new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE)]), new Definition(XmlFileLoader::class, [$configDir.'/serialization.xml']), new Definition(YamlFileLoader::class, [$configDir.'/serialization.yml']), new Definition(YamlFileLoader::class, [$projectDir.'/config/serializer/foo.yml']), diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index b6dd28d614..5e3b3c102e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -29,7 +29,7 @@ "symfony/polyfill-php80": "^1.15", "symfony/filesystem": "^4.4|^5.0", "symfony/finder": "^4.4|^5.0", - "symfony/routing": "^5.1" + "symfony/routing": "^5.2" }, "require-dev": { "doctrine/annotations": "~1.7",