Skip to content

Commit ea5a3cc

Browse files
Remove ClassMetadataFactoryCompiler and other legacy cleanups
1 parent 010092e commit ea5a3cc

File tree

10 files changed

+15
-297
lines changed

10 files changed

+15
-297
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`, replaced by attributes on the `Form` class
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 & 61 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,11 +53,8 @@
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;
62-
use Symfony\Component\DependencyInjection\Argument\ArgumentTrait;
6358
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
6459
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
6560
use Symfony\Component\DependencyInjection\ChildDefinition;
@@ -83,7 +78,6 @@
8378
use Symfony\Component\Filesystem\Filesystem;
8479
use Symfony\Component\Finder\Finder;
8580
use Symfony\Component\Finder\Glob;
86-
use Symfony\Component\Form\EnumFormTypeGuesser;
8781
use Symfony\Component\Form\Form;
8882
use Symfony\Component\Form\FormTypeExtensionInterface;
8983
use Symfony\Component\Form\FormTypeGuesserInterface;
@@ -106,7 +100,6 @@
106100
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
107101
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
108102
use Symfony\Component\HttpKernel\Log\DebugLoggerConfigurator;
109-
use Symfony\Component\HttpKernel\Profiler\ProfilerStateChecker;
110103
use Symfony\Component\JsonStreamer\Attribute\JsonStreamable;
111104
use Symfony\Component\JsonStreamer\JsonStreamWriter;
112105
use Symfony\Component\JsonStreamer\StreamReaderInterface;
@@ -123,11 +116,9 @@
123116
use Symfony\Component\Messenger\Attribute\AsMessage;
124117
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
125118
use Symfony\Component\Messenger\Bridge as MessengerBridge;
126-
use Symfony\Component\Messenger\EventListener\ResetMemoryUsageListener;
127119
use Symfony\Component\Messenger\Handler\BatchHandlerInterface;
128120
use Symfony\Component\Messenger\MessageBus;
129121
use Symfony\Component\Messenger\MessageBusInterface;
130-
use Symfony\Component\Messenger\Middleware\DeduplicateMiddleware;
131122
use Symfony\Component\Messenger\Middleware\RouterContextMiddleware;
132123
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
133124
use Symfony\Component\Messenger\Transport\TransportFactoryInterface as MessengerTransportFactoryInterface;
@@ -164,12 +155,10 @@
164155
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
165156
use Symfony\Component\RemoteEvent\RemoteEvent;
166157
use Symfony\Component\Routing\Attribute\Route;
167-
use Symfony\Component\Routing\Loader\AttributeServicesLoader;
168158
use Symfony\Component\Scheduler\Attribute\AsCronTask;
169159
use Symfony\Component\Scheduler\Attribute\AsPeriodicTask;
170160
use Symfony\Component\Scheduler\Attribute\AsSchedule;
171161
use Symfony\Component\Scheduler\Messenger\SchedulerTransportFactory;
172-
use Symfony\Component\Scheduler\Messenger\Serializer\Normalizer\SchedulerTriggerNormalizer;
173162
use Symfony\Component\Security\Core\AuthenticationEvents;
174163
use Symfony\Component\Security\Core\Exception\AuthenticationException;
175164
use Symfony\Component\Security\Csrf\CsrfToken;
@@ -179,7 +168,6 @@
179168
use Symfony\Component\Semaphore\SemaphoreFactory;
180169
use Symfony\Component\Semaphore\Store\StoreFactory as SemaphoreStoreFactory;
181170
use Symfony\Component\Serializer\Attribute as SerializerMapping;
182-
use Symfony\Component\Serializer\DependencyInjection\AttributeMetadataPass as SerializerAttributeMetadataPass;
183171
use Symfony\Component\Serializer\Encoder\DecoderInterface;
184172
use Symfony\Component\Serializer\Encoder\EncoderInterface;
185173
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
@@ -205,9 +193,7 @@
205193
use Symfony\Component\Uid\UuidV4;
206194
use Symfony\Component\Validator\Constraint;
207195
use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider;
208-
use Symfony\Component\Validator\Constraints\Traverse;
209196
use Symfony\Component\Validator\ConstraintValidatorInterface;
210-
use Symfony\Component\Validator\DependencyInjection\AttributeMetadataPass as ValidatorAttributeMetadataPass;
211197
use Symfony\Component\Validator\GroupProviderInterface;
212198
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
213199
use Symfony\Component\Validator\ObjectInitializerInterface;
@@ -676,12 +662,6 @@ public function load(array $configs, ContainerBuilder $container): void
676662
->addTag('kernel.locale_aware');
677663
$container->registerForAutoconfiguration(ResetInterface::class)
678664
->addTag('kernel.reset', ['method' => 'reset']);
679-
680-
if (!interface_exists(MarshallerInterface::class)) {
681-
$container->registerForAutoconfiguration(ResettableInterface::class)
682-
->addTag('kernel.reset', ['method' => 'reset']);
683-
}
684-
685665
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
686666
->addTag('property_info.list_extractor');
687667
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
@@ -843,10 +823,6 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
843823
{
844824
$loader->load('form.php');
845825

846-
if (!class_exists(EnumFormTypeGuesser::class)) {
847-
$container->removeDefinition('form.type_guesser.enum_type');
848-
}
849-
850826
if (null === $config['form']['csrf_protection']['enabled']) {
851827
$this->writeConfigEnabled('form.csrf_protection', $config['csrf_protection']['enabled'], $config['form']['csrf_protection']);
852828
}
@@ -945,11 +921,6 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
945921
$loader->load('collectors.php');
946922
$loader->load('cache_debug.php');
947923

948-
if (!class_exists(ProfilerStateChecker::class)) {
949-
$container->removeDefinition('profiler.state_checker');
950-
$container->removeDefinition('profiler.is_disabled_state_checker');
951-
}
952-
953924
if ($this->isInitializedConfigEnabled('form')) {
954925
$loader->load('form_debug.php');
955926
}
@@ -1006,13 +977,9 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
1006977
$container->getDefinition('profiler_listener')
1007978
->addArgument($config['collect_parameter']);
1008979

1009-
if (!$container->getParameter('kernel.debug') || !class_exists(CliRequest::class) || !$container->has('debug.stopwatch')) {
980+
if (!$container->getParameter('kernel.debug') || !$container->has('debug.stopwatch')) {
1010981
$container->removeDefinition('console_profiler_listener');
1011982
}
1012-
1013-
if (!class_exists(CommandDataCollector::class)) {
1014-
$container->removeDefinition('.data_collector.command');
1015-
}
1016983
}
1017984

1018985
private function registerWorkflowConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
@@ -1270,10 +1237,6 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
12701237

12711238
$loader->load('routing.php');
12721239

1273-
if (!class_exists(AttributeServicesLoader::class)) {
1274-
$container->removeDefinition('routing.loader.attribute.services');
1275-
}
1276-
12771240
if ($config['utf8']) {
12781241
$container->getDefinition('routing.loader')->replaceArgument(1, ['utf8' => true]);
12791242
}
@@ -1766,7 +1729,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
17661729

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

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

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

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

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

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

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

22992249
private function registerMessengerConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $validationEnabled, bool $lockEnabled): void
@@ -2312,10 +2262,6 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
23122262
$container->removeDefinition('serializer.normalizer.flatten_exception');
23132263
}
23142264

2315-
if (!class_exists(ResetMemoryUsageListener::class)) {
2316-
$container->removeDefinition('messenger.listener.reset_memory_usage');
2317-
}
2318-
23192265
if (ContainerBuilder::willBeAvailable('symfony/amqp-messenger', MessengerBridge\Amqp\Transport\AmqpTransportFactory::class, ['symfony/framework-bundle', 'symfony/messenger'])) {
23202266
$container->getDefinition('messenger.transport.amqp.factory')->addTag('messenger.transport_factory');
23212267
}
@@ -2356,7 +2302,7 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
23562302
],
23572303
];
23582304

2359-
if ($lockEnabled && class_exists(DeduplicateMiddleware::class) && class_exists(LockFactory::class)) {
2305+
if ($lockEnabled && class_exists(LockFactory::class)) {
23602306
$defaultMiddleware['before'][] = ['id' => 'deduplicate_middleware'];
23612307
} else {
23622308
$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`, replaced by attributes on the `Form` class
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/Form/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"symfony/var-dumper": "^7.4|^8.0"
4545
},
4646
"conflict": {
47-
"symfony/translation-contracts": "<2.5"
47+
"symfony/translation-contracts": "<2.5",
48+
"symfony/validator": "<7.4"
4849
},
4950
"autoload": {
5051
"psr-4": { "Symfony\\Component\\Form\\": "" },

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)