Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] Configure PHP Attributes without doctrine/annotations.
  • Loading branch information
derrabus committed Nov 7, 2020
commit e5492e2e55d11a296bb2d68d45a3aac3e914df84
Original file line number Diff line number Diff line change
Expand Up @@ -965,11 +965,11 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
->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)
Expand Down Expand Up @@ -1564,13 +1564,13 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder

$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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ public function testSerializerMapping()
$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']),
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down