Skip to content

Commit 3e73674

Browse files
Remove ClassMetadataFactoryCompiler and other legacy cleanups
1 parent b879a65 commit 3e73674

File tree

9 files changed

+13
-295
lines changed

9 files changed

+13
-295
lines changed

UPGRADE-8.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ Form
165165
* Made `ResizeFormListener::postSetData()` method `final`
166166
* Remove the `VersionAwareTest` trait, use feature detection instead
167167
* Remove deprecated `ResizeFormListener::preSetData()` method, use `postSetData()` instead
168+
* Remove `validation.xml` in `Resources/config`
168169

169170
FrameworkBundle
170171
---------------
@@ -464,7 +465,7 @@ Serializer
464465
+public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
465466
```
466467
* Remove `AdvancedNameConverterInterface`, use `NameConverterInterface` instead
467-
* Remove the `CompiledClassMetadataFactory` and `CompiledClassMetadataCacheWarmer` classes
468+
* Remove `ClassMetadataFactoryCompiler`, `CompiledClassMetadataFactory` and `CompiledClassMetadataCacheWarmer`
468469
* Remove class aliases in the `Annotation` namespace, use attributes instead
469470
* Remove getters in attribute classes in favor of public properties
470471

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

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
use Symfony\Component\Cache\Adapter\ChainAdapter;
4444
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
4545
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
46-
use Symfony\Component\Cache\Marshaller\MarshallerInterface;
47-
use Symfony\Component\Cache\ResettableInterface;
4846
use Symfony\Component\Clock\ClockInterface;
4947
use Symfony\Component\Config\Definition\ConfigurationInterface;
5048
use Symfony\Component\Config\FileLocator;
@@ -55,8 +53,6 @@
5553
use Symfony\Component\Console\Application;
5654
use Symfony\Component\Console\Attribute\AsCommand;
5755
use Symfony\Component\Console\Command\Command;
58-
use Symfony\Component\Console\DataCollector\CommandDataCollector;
59-
use Symfony\Component\Console\Debug\CliRequest;
6056
use Symfony\Component\Console\Messenger\RunCommandMessageHandler;
6157
use Symfony\Component\DependencyInjection\Alias;
6258
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
@@ -82,7 +78,6 @@
8278
use Symfony\Component\Filesystem\Filesystem;
8379
use Symfony\Component\Finder\Finder;
8480
use Symfony\Component\Finder\Glob;
85-
use Symfony\Component\Form\EnumFormTypeGuesser;
8681
use Symfony\Component\Form\Form;
8782
use Symfony\Component\Form\FormTypeExtensionInterface;
8883
use Symfony\Component\Form\FormTypeGuesserInterface;
@@ -105,7 +100,6 @@
105100
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
106101
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
107102
use Symfony\Component\HttpKernel\Log\DebugLoggerConfigurator;
108-
use Symfony\Component\HttpKernel\Profiler\ProfilerStateChecker;
109103
use Symfony\Component\JsonStreamer\Attribute\JsonStreamable;
110104
use Symfony\Component\JsonStreamer\JsonStreamWriter;
111105
use Symfony\Component\JsonStreamer\StreamReaderInterface;
@@ -122,11 +116,9 @@
122116
use Symfony\Component\Messenger\Attribute\AsMessage;
123117
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
124118
use Symfony\Component\Messenger\Bridge as MessengerBridge;
125-
use Symfony\Component\Messenger\EventListener\ResetMemoryUsageListener;
126119
use Symfony\Component\Messenger\Handler\BatchHandlerInterface;
127120
use Symfony\Component\Messenger\MessageBus;
128121
use Symfony\Component\Messenger\MessageBusInterface;
129-
use Symfony\Component\Messenger\Middleware\DeduplicateMiddleware;
130122
use Symfony\Component\Messenger\Middleware\RouterContextMiddleware;
131123
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
132124
use Symfony\Component\Messenger\Transport\TransportFactoryInterface as MessengerTransportFactoryInterface;
@@ -163,12 +155,10 @@
163155
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
164156
use Symfony\Component\RemoteEvent\RemoteEvent;
165157
use Symfony\Component\Routing\Attribute\Route;
166-
use Symfony\Component\Routing\Loader\AttributeServicesLoader;
167158
use Symfony\Component\Scheduler\Attribute\AsCronTask;
168159
use Symfony\Component\Scheduler\Attribute\AsPeriodicTask;
169160
use Symfony\Component\Scheduler\Attribute\AsSchedule;
170161
use Symfony\Component\Scheduler\Messenger\SchedulerTransportFactory;
171-
use Symfony\Component\Scheduler\Messenger\Serializer\Normalizer\SchedulerTriggerNormalizer;
172162
use Symfony\Component\Security\Core\AuthenticationEvents;
173163
use Symfony\Component\Security\Core\Exception\AuthenticationException;
174164
use Symfony\Component\Security\Csrf\CsrfToken;
@@ -178,7 +168,6 @@
178168
use Symfony\Component\Semaphore\SemaphoreFactory;
179169
use Symfony\Component\Semaphore\Store\StoreFactory as SemaphoreStoreFactory;
180170
use Symfony\Component\Serializer\Attribute as SerializerMapping;
181-
use Symfony\Component\Serializer\DependencyInjection\AttributeMetadataPass as SerializerAttributeMetadataPass;
182171
use Symfony\Component\Serializer\Encoder\DecoderInterface;
183172
use Symfony\Component\Serializer\Encoder\EncoderInterface;
184173
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
@@ -204,9 +193,7 @@
204193
use Symfony\Component\Uid\UuidV4;
205194
use Symfony\Component\Validator\Constraint;
206195
use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider;
207-
use Symfony\Component\Validator\Constraints\Traverse;
208196
use Symfony\Component\Validator\ConstraintValidatorInterface;
209-
use Symfony\Component\Validator\DependencyInjection\AttributeMetadataPass as ValidatorAttributeMetadataPass;
210197
use Symfony\Component\Validator\GroupProviderInterface;
211198
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
212199
use Symfony\Component\Validator\ObjectInitializerInterface;
@@ -675,12 +662,6 @@ public function load(array $configs, ContainerBuilder $container): void
675662
->addTag('kernel.locale_aware');
676663
$container->registerForAutoconfiguration(ResetInterface::class)
677664
->addTag('kernel.reset', ['method' => 'reset']);
678-
679-
if (!interface_exists(MarshallerInterface::class)) {
680-
$container->registerForAutoconfiguration(ResettableInterface::class)
681-
->addTag('kernel.reset', ['method' => 'reset']);
682-
}
683-
684665
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
685666
->addTag('property_info.list_extractor');
686667
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
@@ -842,10 +823,6 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
842823
{
843824
$loader->load('form.php');
844825

845-
if (!class_exists(EnumFormTypeGuesser::class)) {
846-
$container->removeDefinition('form.type_guesser.enum_type');
847-
}
848-
849826
if (null === $config['form']['csrf_protection']['enabled']) {
850827
$this->writeConfigEnabled('form.csrf_protection', $config['csrf_protection']['enabled'], $config['form']['csrf_protection']);
851828
}
@@ -944,11 +921,6 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
944921
$loader->load('collectors.php');
945922
$loader->load('cache_debug.php');
946923

947-
if (!class_exists(ProfilerStateChecker::class)) {
948-
$container->removeDefinition('profiler.state_checker');
949-
$container->removeDefinition('profiler.is_disabled_state_checker');
950-
}
951-
952924
if ($this->isInitializedConfigEnabled('form')) {
953925
$loader->load('form_debug.php');
954926
}
@@ -1005,13 +977,9 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
1005977
$container->getDefinition('profiler_listener')
1006978
->addArgument($config['collect_parameter']);
1007979

1008-
if (!$container->getParameter('kernel.debug') || !class_exists(CliRequest::class) || !$container->has('debug.stopwatch')) {
980+
if (!$container->getParameter('kernel.debug') || !$container->has('debug.stopwatch')) {
1009981
$container->removeDefinition('console_profiler_listener');
1010982
}
1011-
1012-
if (!class_exists(CommandDataCollector::class)) {
1013-
$container->removeDefinition('.data_collector.command');
1014-
}
1015983
}
1016984

1017985
private function registerWorkflowConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
@@ -1269,10 +1237,6 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
12691237

12701238
$loader->load('routing.php');
12711239

1272-
if (!class_exists(AttributeServicesLoader::class)) {
1273-
$container->removeDefinition('routing.loader.attribute.services');
1274-
}
1275-
12761240
if ($config['utf8']) {
12771241
$container->getDefinition('routing.loader')->replaceArgument(1, ['utf8' => true]);
12781242
}
@@ -1765,7 +1729,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
17651729

17661730
// When attributes are disabled, it means from runtime-discovery only; autoconfiguration should still happen.
17671731
// And when runtime-discovery of attributes is enabled, we can skip compile-time autoconfiguration in debug mode.
1768-
if (class_exists(ValidatorAttributeMetadataPass::class) && (!($config['enable_attributes'] ?? false) || !$container->getParameter('kernel.debug'))) {
1732+
if (!($config['enable_attributes'] ?? false) || !$container->getParameter('kernel.debug')) {
17691733
// The $reflector argument hints at where the attribute could be used
17701734
$container->registerAttributeForAutoconfiguration(Constraint::class, function (ChildDefinition $definition, Constraint $attribute, \ReflectionClass|\ReflectionMethod|\ReflectionProperty $reflector) {
17711735
$definition->addTag('validator.attribute_metadata');
@@ -1817,9 +1781,6 @@ private function registerValidatorMapping(ContainerBuilder $container, array $co
18171781

18181782
if (!ContainerBuilder::willBeAvailable('symfony/form', Form::class, ['symfony/framework-bundle', 'symfony/validator'])) {
18191783
$container->removeDefinition('validator.form.attribute_metadata');
1820-
} elseif (!($r = new \ReflectionClass(Form::class))->getAttributes(Traverse::class) || !class_exists(ValidatorAttributeMetadataPass::class)) {
1821-
// BC with symfony/form & symfony/validator < 7.4
1822-
$fileRecorder('xml', \dirname($r->getFileName()).'/Resources/config/validation.xml');
18231784
}
18241785

18251786
foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
@@ -2015,7 +1976,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
20151976

20161977
// When attributes are disabled, it means from runtime-discovery only; autoconfiguration should still happen.
20171978
// And when runtime-discovery of attributes is enabled, we can skip compile-time autoconfiguration in debug mode.
2018-
if (class_exists(SerializerAttributeMetadataPass::class) && (!($config['enable_attributes'] ?? false) || !$container->getParameter('kernel.debug'))) {
1979+
if (!($config['enable_attributes'] ?? false) || !$container->getParameter('kernel.debug')) {
20191980
// The $reflector argument hints at where the attribute could be used
20201981
$configurator = function (ChildDefinition $definition, object $attribute, \ReflectionClass|\ReflectionMethod|\ReflectionProperty $reflector) {
20211982
$definition->addTag('serializer.attribute_metadata');
@@ -2036,15 +1997,10 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
20361997
});
20371998
}
20381999

2039-
if (($config['enable_attributes'] ?? false) || class_exists(SerializerAttributeMetadataPass::class)) {
2040-
$serializerLoaders[] = new Reference('serializer.mapping.attribute_loader');
2000+
$serializerLoaders[] = new Reference('serializer.mapping.attribute_loader');
20412001

2042-
$container->getDefinition('serializer.mapping.attribute_loader')
2043-
->replaceArgument(0, $config['enable_attributes'] ?? false);
2044-
} else {
2045-
// BC with symfony/serializer < 7.4
2046-
$container->removeDefinition('serializer.mapping.attribute_services_loader');
2047-
}
2002+
$container->getDefinition('serializer.mapping.attribute_loader')
2003+
->replaceArgument(0, $config['enable_attributes'] ?? false);
20482004

20492005
$fileRecorder = function ($extension, $path) use (&$serializerLoaders) {
20502006
$definition = new Definition(\in_array($extension, ['yaml', 'yml'], true) ? YamlFileLoader::class : XmlFileLoader::class, [$path]);
@@ -2288,11 +2244,6 @@ private function registerSchedulerConfiguration(ContainerBuilder $container, Php
22882244
if (!$this->hasConsole()) {
22892245
$container->removeDefinition('console.command.scheduler_debug');
22902246
}
2291-
2292-
// BC layer Scheduler < 7.3
2293-
if (!ContainerBuilder::willBeAvailable('symfony/serializer', DenormalizerInterface::class, ['symfony/framework-bundle', 'symfony/scheduler']) || !class_exists(SchedulerTriggerNormalizer::class)) {
2294-
$container->removeDefinition('serializer.normalizer.scheduler_trigger');
2295-
}
22962247
}
22972248

22982249
private function registerMessengerConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $validationEnabled, bool $lockEnabled): void
@@ -2311,10 +2262,6 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
23112262
$container->removeDefinition('serializer.normalizer.flatten_exception');
23122263
}
23132264

2314-
if (!class_exists(ResetMemoryUsageListener::class)) {
2315-
$container->removeDefinition('messenger.listener.reset_memory_usage');
2316-
}
2317-
23182265
if (ContainerBuilder::willBeAvailable('symfony/amqp-messenger', MessengerBridge\Amqp\Transport\AmqpTransportFactory::class, ['symfony/framework-bundle', 'symfony/messenger'])) {
23192266
$container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
23202267
}
@@ -2355,7 +2302,7 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
23552302
],
23562303
];
23572304

2358-
if ($lockEnabled && class_exists(DeduplicateMiddleware::class) && class_exists(LockFactory::class)) {
2305+
if ($lockEnabled && class_exists(LockFactory::class)) {
23592306
$defaultMiddleware['before'][] = ['id' => 'deduplicate_middleware'];
23602307
} else {
23612308
$container->removeDefinition('messenger.middleware.deduplicate_middleware');

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* Change default value of `default_protocol` option in `UrlType` from `'http'` to `null`
88
* Remove the `VersionAwareTest` trait, use feature detection instead
99
* Remove deprecated `ResizeFormListener::preSetData()` method, use `postSetData()` instead
10+
* Remove `validation.xml` in `Resources/config`
1011

1112
7.4
1213
---

src/Symfony/Component/Form/Resources/config/validation.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\HttpKernel\EventListener;
1313

14-
use Psr\Log\LoggerInterface;
1514
use Symfony\Component\Console\ConsoleEvents;
1615
use Symfony\Component\Console\Event\ConsoleEvent;
1716
use Symfony\Component\Console\Output\ConsoleOutputInterface;
@@ -38,16 +37,10 @@ class DebugHandlersListener implements EventSubscriberInterface
3837
private bool $hasTerminatedWithException = false;
3938

4039
/**
41-
* @param bool $webMode
4240
* @param callable|null $exceptionHandler A handler that must support \Throwable instances that will be called on Exception
4341
*/
44-
public function __construct(?callable $exceptionHandler = null, bool|LoggerInterface|null $webMode = null)
42+
public function __construct(?callable $exceptionHandler = null, ?bool $webMode = null)
4543
{
46-
if ($webMode instanceof LoggerInterface) {
47-
// BC with Symfony 5
48-
$webMode = null;
49-
}
50-
5144
$handler = set_exception_handler('var_dump');
5245
$this->earlyHandler = \is_array($handler) ? $handler[0] : null;
5346
restore_exception_handler();

src/Symfony/Component/Serializer/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CHANGELOG
2323
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
2424
```
2525
* Remove `AdvancedNameConverterInterface`, use `NameConverterInterface` instead
26-
* Remove the `CompiledClassMetadataFactory` and `CompiledClassMetadataCacheWarmer` classes
26+
* Remove `ClassMetadataFactoryCompiler`, `CompiledClassMetadataFactory` and `CompiledClassMetadataCacheWarmer`
2727
* Remove class aliases in the `Annotation` namespace, use attributes instead
2828
* Remove getters in attribute classes in favor of public properties
2929

src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactoryCompiler.php

Lines changed: 0 additions & 73 deletions
This file was deleted.

src/Symfony/Component/Serializer/Mapping/Loader/AttributeLoader.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ class AttributeLoader implements LoaderInterface
4444
];
4545

4646
/**
47-
* @param bool|null $allowAnyClass Null is allowed for BC with Symfony <= 6
4847
* @param class-string[] $mappedClasses
4948
*/
5049
public function __construct(
51-
private ?bool $allowAnyClass = true,
50+
private bool $allowAnyClass = true,
5251
private array $mappedClasses = [],
5352
) {
54-
$this->allowAnyClass ??= true;
5553
}
5654

5755
/**

0 commit comments

Comments
 (0)