8000 [FrameworkBundle] Remove doctrine/annotations integration · symfony/symfony@cbf8a2e · GitHub
[go: up one dir, main page]

Skip to content

Commit cbf8a2e

Browse files
committed
[FrameworkBundle] Remove doctrine/annotations integration
1 parent 7ab9a44 commit cbf8a2e

21 files changed

+26
-641
lines changed

UPGRADE-7.0.md

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ FrameworkBundle
121121
$this->render(..., ['form' => $form]);
122122
```
123123

124+
* Remove the integration of Doctrine annotations
125+
124126
HttpFoundation
125127
--------------
126128

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CHANGELOG
1111
`Symfony\Component\Serializer\Normalizer\PropertyNormalizer` autowiring aliases, type-hint against
1212
`Symfony\Component\Serializer\Normalizer\NormalizerInterface` or implement `NormalizerAwareInterface` instead
1313
* Remove the `Http\Client\HttpClient` service, use `Psr\Http\Client\ClientInterface` instead
14+
* Remove the integration of Doctrine annotations
1415

1516
6.4
1617
---

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php

-114
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@ class UnusedTagsPass implements CompilerPassInterface
2323
{
2424
private const KNOWN_TAGS = [
2525
'annotations.cached_reader',
26-
'assets.package',
2726
'asset_mapper.compiler',
2827
'asset_mapper.importmap.resolver',
28+
'assets.package',
2929
'auto_alias',
3030
'cache.pool',
3131
'cache.pool.clearer',
3232
'cache.taggable',
3333
'chatter.transport_factory',
3434
'config_cache.resource_checker',
3535
'console.command',
36-
'container.do_not_inline',
3736
'container.env_var_loader',
3837
'container.env_var_processor',
3938
'container.excluded',

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

+6-13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
1313

14-
use Doctrine\Common\Annotations\Annotation;
1514
use Doctrine\DBAL\Connection;
1615
use Psr\Log\LogLevel;
1716
use Symfony\Bundle\FullStack;
@@ -155,7 +154,7 @@ public function getConfigTreeBuilder(): TreeBuilder
155154
$this->addAssetMapperSection($rootNode, $enableIfStandalone);
156155
$this->addTranslatorSection($rootNode, $enableIfStandalone);
157156
$this->addValidationSection($rootNode, $enableIfStandalone);
158-
$this->addAnnotationsSection($rootNode, $willBeAvailable);
157+
$this->addAnnotationsSection($rootNode);
159158
$this->addSerializerSection($rootNode, $enableIfStandalone);
160159
$this->addPropertyAccessSection($rootNode, $willBeAvailable);
161160
$this->addPropertyInfoSection($rootNode, $enableIfStandalone);
@@ -1057,21 +1056,15 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e
10571056
;
10581057
}
10591058

1060-
private function addAnnotationsSection(ArrayNodeDefinition $rootNode, callable $willBeAvailable): void
1059+
private function addAnnotationsSection(ArrayNodeDefinition $rootNode): void
10611060
{
10621061
$rootNode
10631062
->children()
10641063
->arrayNode('annotations')
1065-
->info('annotation configuration')
1066-
->{$willBeAvailable('doctrine/annotations', Annotation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
1067-
->children()
1068-
->enumNode('cache')
1069-
->values(['none', 'php_array', 'file'])
1070-
->defaultValue('php_array')
1071-
->end()
1072-
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
1073-
->booleanNode('debug')->defaultValue($this->debug)->end()
1074-
->end()
1064+
->canBeEnabled()
1065+
->validate()
1066+
->ifTrue(static fn (array $v) => $v['enabled'])
1067+
->thenInvalid('Enabling the doctrine/annotations integration is not supported anymore.')
10751068
->end()
10761069
->end()
10771070
;

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

+1-59
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
1313

1414
use Composer\InstalledVersions;
15-
use Doctrine\Common\Annotations\Reader;
1615
use Http\Client\HttpAsyncClient;
1716
use Http\Client\HttpClient;
1817
use phpDocumentor\Reflection\DocBlockFactoryInterface;
@@ -255,7 +254,6 @@ public function load(array $configs, ContainerBuilder $container): void
255254
$config = $this->processConfiguration($configuration, $configs);
256255

257256
// warmup config enabled
258-
$this->readConfigEnabled('annotations', $container, $config['annotations']);
259257
$this->readConfigEnabled('translator', $container, $config['translator']);
260258
$this->readConfigEnabled('property_access', $container, $config['property_access']);
261259
$this->readConfigEnabled('profiler', $container, $config['profiler']);
@@ -363,7 +361,6 @@ public function load(array $configs, ContainerBuilder $container): void
363361
$this->registerWorkflowConfiguration($config['workflows'], $container, $loader);
364362
$this->registerDebugConfiguration($config['php_errors'], $container, $loader);
365363
$this->registerRouterConfiguration($config['router'], $container, $loader, $config['enabled_locales']);
366-
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
367364
$this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader);
368365
$this->registerSecretsConfiguration($config['secrets'], $container, $loader);
369366

@@ -1600,10 +1597,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
16001597
$definition->replaceArgument(0, $config['email_validation_mode']);
16011598

16021599
if (\array_key_exists('enable_annotations', $config) && $config['enable_annotations']) {
1603-
$validatorBuilder->addMethodCall('enableAnnotationMapping', [true]);
1604-
if ($this->isInitializedConfigEnabled('annotations')) {
1605-
$validatorBuilder->addMethodCall('setDoctrineAnnotationReader', [new Reference('annotation_reader')]);
1606-
}
1600+
$validatorBuilder->addMethodCall('enableAnnotationMapping');
16071601
}
16081602

16091603
if (\array_key_exists('static_method', $config) && $config['static_method']) {
@@ -1698,58 +1692,6 @@ private function registerMappingFilesFromConfig(ContainerBuilder $container, arr
16981692
}
16991693
}
17001694

1701-
private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader): void
1702-
{
1703-
if (!$this->isInitializedConfigEnabled('annotations')) {
1704-
return;
1705-
}
1706-
1707-
if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) {
1708-
throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed. Try running "composer require doctrine/annotations".');
1709-
}
1710-
1711-
trigger_deprecation('symfony/framework-bundle', '6.4', 'Enabling the integration of Doctrine annotations is deprecated. Set the "framework.annotations.enabled" config option to false.');
1712-
1713-
$loader->load('annotations.php');
1714-
1715-
if ('none' === $config['cache']) {
1716-
$container->removeDefinition('annotations.cached_reader');
1717-
1718-
return;
1719-
}
1720-
1721-
if ('php_array' === $config['cache']) {
1722-
$cacheService = 'annotations.cache_adapter';
1723-
1724-
// Enable warmer only if PHP array is used for cache
1725-
$definition = $container->findDefinition('annotations.cache_warmer');
1726-
$definition->addTag('kernel.cache_warmer');
1727-
} else {
1728-
$cacheService = 'annotations.filesystem_cache_adapter';
1729-
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
1730-
1731-
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
1732-
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
1733-
}
1734-
1735-
$container
1736-
->getDefinition('annotations.filesystem_cache_adapter')
1737-
->replaceArgument(2, $cacheDir)
1738-
;
1739-
}
1740-
1741-
$container
1742-
->getDefinition('annotations.cached_reader')
1743-
->replaceArgument(2, $config['debug'])
1744-
// reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
1745-
->addArgument(new ServiceClosureArgument(new Reference($cacheService)))
1746-
;
1747-
1748-
$container->setAlias('annotation_reader', 'annotations.cached_reader');
1749-
$container->setAlias(Reader::class, new Alias('annotations.cached_reader', false));
1750-
$container->removeDefinition('annotations.psr_cached_reader');
1751-
}
1752-
17531695
private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
17541696
{
17551697
if (!$this->readConfigEnabled('property_access', $container, $config)) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.php

-71
This file was deleted.

0 commit comments

Comments
 (0)
0