10000 [FrameworkBundle] Remove doctrine/annotations integration by derrabus · Pull Request #51050 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Remove doctrine/annotations integration #51050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2023
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
2 changes: 2 additions & 0 deletions UPGRADE-7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ FrameworkBundle
$this->render(..., ['form' => $form]);
```

* Remove the integration of Doctrine annotations, use native attributes instead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not supposed to be removed in Symfony 8?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #50888, you said:

The plan is to make this the default and only valid option in Symfony 7 and remove that setting entirely in Symfony 8.

Copy link
Contributor
@Seb33300 Seb33300 Jul 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh sorry, just got it. The option cannot be enabled on Symfony 7

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the setting is still there. You just cannot enable it.


HttpFoundation
--------------

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CHANGELOG
`Symfony\Component\Serializer\Normalizer\PropertyNormalizer` autowiring aliases, type-hint against
`Symfony\Component\Serializer\Normalizer\NormalizerInterface` or implement `NormalizerAwareInterface` instead
* Remove the `Http\Client\HttpClient` service, use `Psr\Http\Client\ClientInterface` instead
* Remove the integration of Doctrine annotations, use native attributes instead

6.4
---
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ class UnusedTagsPass implements CompilerPassInterface
{
private const KNOWN_TAGS = [
'annotations.cached_reader',
'assets.package',
'asset_mapper.compiler',
'asset_mapper.importmap.resolver',
'assets.package',
'auto_alias',
'cache.pool',
'cache.pool.clearer',
'cache.taggable',
'chatter.transport_factory',
'config_cache.resource_checker',
'console.command',
'container.do_not_inline',
'container.env_var_loader',
'container.env_var_processor',
'container.excluded',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\DBAL\Connection;
use Psr\Log\LogLevel;
use Symfony\Bundle\FullStack;
Expand Down Expand Up @@ -155,7 +154,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$this->addAssetMapperSection($rootNode, $enableIfStandalone);
$this->addTranslatorSection($rootNode, $enableIfStandalone);
$this->addValidationSection($rootNode, $enableIfStandalone);
$this->addAnnotationsSection($rootNode, $willBeAvailable);
$this->addAnnotationsSection($rootNode);
$this->addSerializerSection($rootNode, $enableIfStandalone);
$this->addPropertyAccessSection($rootNode, $willBeAvailable);
$this->addPropertyInfoSection($rootNode, $enableIfStandalone);
Expand Down Expand Up @@ -1057,21 +1056,15 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e
;
}

private function addAnnotationsSection(ArrayNodeDefinition $rootNode, callable $willBeAvailable): void
private function addAnnotationsSection(ArrayNodeDefinition $rootNode): void
{
$rootNode
->children()
->arrayNode('annotations')
->info('annotation configuration')
->{$willBeAvailable('doctrine/annotations', Annotation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->children()
->enumNode('cache')
->values(['none', 'php_array', 'file'])
->defaultValue('php_array')
->end()
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
->booleanNode('debug')->defaultValue($this->debug)->end()
->end()
->canBeEnabled()
->validate()
->ifTrue(static fn (array $v) => $v['enabled'])
->thenInvalid('Enabling the doctrine/annotations integration is not supported anymore.')
->end()
->end()
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;

use Composer\InstalledVersions;
use Doctrine\Common\Annotations\Reader;
use Http\Client\HttpAsyncClient;
use Http\Client\HttpClient;
use phpDocumentor\Reflection\DocBlockFactoryInterface;
Expand Down Expand Up @@ -54,7 +53,6 @@
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -255,7 +253,6 @@ public function load(array $configs, ContainerBuilder $container): void
$config = $this->processConfiguration($configuration, $configs);

// warmup config enabled
$this->readConfigEnabled('annotations', $container, $config['annotations']);
$this->readConfigEnabled('translator', $container, $config['translator']);
$this->readConfigEnabled('property_access', $container, $config['property_access']);
$this->readConfigEnabled('profiler', $container, $config['profiler']);
Expand Down Expand Up @@ -363,7 +360,6 @@ public function load(array $configs, ContainerBuilder $container): void
$this->registerWorkflowConfiguration($config['workflows'], $container, $loader);
$this->registerDebugConfiguration($config['php_errors'], $container, $loader);
$this->registerRouterConfiguration($config['router'], $container, $loader, $config['enabled_locales']);
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
$this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader);
$this->registerSecretsConfiguration($config['secrets'], $container, $loader);

Expand Down Expand Up @@ -1600,10 +1596,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
$definition->replaceArgument(0, $config['email_validation_mode']);

if (\array_key_exists('enable_annotations', $config) && $config['enable_annotations']) {
$validatorBuilder->addMethodCall('enableAnnotationMapping', [true]);
if ($this->isInitializedConfigEnabled('annotations')) {
$validatorBuilder->addMethodCall('setDoctrineAnnotationReader', [new Reference('annotation_reader')]);
}
$validatorBuilder->addMethodCall('enableAnnotationMapping');
}

if (\array_key_exists('static_method', $config) && $config['static_method']) {
Expand Down Expand Up @@ -1698,58 +1691,6 @@ private function registerMappingFilesFromConfig(ContainerBuilder $container, arr
}
}

private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader): void
{
if (!$this->isInitializedConfigEnabled('annotations')) {
return;
}

if (!class_exists(\Doctrine\Common\Annotations\Annotation::class)) {
throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed. Try running "composer require doctrine/annotations".');
}

trigger_deprecation('symfony/framework-bundle', '6.4', 'Enabling the integration of Doctrine annotations is deprecated. Set the "framework.annotations.enabled" config option to false.');

$loader->load('annotations.php');

if ('none' === $config['cache']) {
$container->removeDefinition('annotations.cached_reader');

return;
}

if ('php_array' === $config['cache']) {
$cacheService = 'annotations.cache_adapter';

// Enable warmer only if PHP array is used for cache
$definition = $container->findDefinition('annotations.cache_warmer');
$definition->addTag('kernel.cache_warmer');
} else {
$cacheService = 'annotations.filesystem_cache_adapter';
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);

if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
}

$container
->getDefinition('annotations.filesystem_cache_adapter')
->replaceArgument(2, $cacheDir)
;
}

$container
->getDefinition('annotations.cached_reader')
->replaceArgument(2, $config['debug'])
// reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
->addArgument(new ServiceClosureArgument(new Reference($cacheService)))
;

$container->setAlias('annotation_reader', 'annotations.cached_reader');
$container->setAlias(Reader::class, new Alias('annotations.cached_reader', false));
$container->removeDefinition('annotations.psr_cached_reader');
}

private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
{
if (!$this->readConfigEnabled('property_access', $container, $config)) {
Expand Down
71 changes: 0 additions & 71 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.php

This file was deleted.

Loading
0