Skip to content

Commit d7a161d

Browse files
committed
bug #20749 [FrameworkBundle] Smarter default for framework.annotations (ogizanagi)
This PR was merged into the 3.2 branch. Discussion ---------- [FrameworkBundle] Smarter default for framework.annotations | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yesish (could be considered as a minor BC break) | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | N/A `framework.annotations` default should be true only if `doctrine/annotations` is installed. Indeed, in symfony/symfony#20097, the dependency on `doctrine/annotations` was removed from the framework bundle. Thus, an application can break (not talking from one actually relying on annotations) as soon as it uses the framework bundle without the `framework.annotations` key explicitly set to `false` (I had the case in a fixture application in the testsuite of a package). Commits ------- e38be09 [FrameworkBundle] framework.annotations default should be true only if doctrine/annotations is installed
2 parents 86cadb5 + db1c487 commit d7a161d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
1313

14+
use Doctrine\Common\Annotations\Annotation;
1415
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1516
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1617
use Symfony\Component\Config\Definition\ConfigurationInterface;
@@ -602,7 +603,7 @@ private function addAnnotationsSection(ArrayNodeDefinition $rootNode)
602603
->children()
603604
->arrayNode('annotations')
604605
->info('annotation configuration')
605-
->canBeDisabled()
606+
->{class_exists(Annotation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
606607
->children()
607608
->scalarNode('cache')->defaultValue('php_array')->end()
608609
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()

0 commit comments

Comments
 (0)