Skip to content

Commit 7562d85

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

File tree

10 files changed

+15
-296
lines changed

10 files changed

+15
-296
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 & 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\ArgumentTrait;
@@ -83,7 +79,6 @@
8379
use Symfony\Component\Filesystem\Filesystem;
8480
use Symfony\Component\Finder\Finder;
8581
use Symfony\Component\Finder\Glob;
86-
use Symfony\Component\Form\EnumFormTypeGuesser;
8782
use Symfony\Component\Form\Form;
8883
use Symfony\Component\Form\FormTypeExtensionInterface;
8984
use Symfony\Component\Form\FormTypeGuesserInterface;
@@ -106,7 +101,6 @@
106101
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
107102
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
108103
use Symfony\Component\HttpKernel\Log\DebugLoggerConfigurator;
109-
use Symfony\Component\HttpKernel\Profiler\ProfilerStateChecker;
110104
use Symfony\Component\JsonStreamer\Attribute\JsonStreamable;
111105
use Symfony\Component\JsonStreamer\JsonStreamWriter;
112106
use Symfony\Component\JsonStreamer\StreamReaderInterface;
@@ -123,11 +117,9 @@
123117
use Symfony\Component\Messenger\Attribute\AsMessage;
124118
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
125119
use Symfony\Component\Messenger\Bridge as MessengerBridge;
126-
use Symfony\Component\Messenger\EventListener\ResetMemoryUsageListener;
127120
use Symfony\Component\Messenger\Handler\BatchHandlerInterface;
128121
use Symfony\Component\Messenger\MessageBus;
129122
use Symfony\Component\Messenger\MessageBusInterface;
130-
use Symfony\Component\Messenger\Middleware\DeduplicateMiddleware;
131123
use Symfony\Component\Messenger\Middleware\RouterContextMiddleware;
132124
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
133125
use Symfony\Component\Messenger\Transport\TransportFactoryInterface as MessengerTransportFactoryInterface;
@@ -164,12 +156,10 @@
164156
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
165157
use Symfony\Component\RemoteEvent\RemoteEvent;
166158
use Symfony\Component\Routing\Attribute\Route;
167-
use Symfony\Component\Routing\Loader\AttributeServicesLoader;
168159
use Symfony\Component\Scheduler\Attribute\AsCronTask;
169160
use Symfony\Component\Scheduler\Attribute\AsPeriodicTask;
170161
use Symfony\Component\Scheduler\Attribute\AsSchedule;
171162
use Symfony\Component\Scheduler\Messenger\SchedulerTransportFactory;
172-
use Symfony\Component\Scheduler\Messenger\Serializer\Normalizer\SchedulerTriggerNormalizer;
173163
use Symfony\Component\Security\Core\AuthenticationEvents;
174164
use Symfony\Component\Security\Core\Exception\AuthenticationException;
175165
use Symfony\Component\Security\Csrf\CsrfToken;
@@ -179,7 +169,6 @@
179169
use Symfony\Component\Semaphore\SemaphoreFactory;
180170
use Symfony\Component\Semaphore\Store\StoreFactory as SemaphoreStoreFactory;
181171
use Symfony\Component\Serializer\Attribute as SerializerMapping;
182-
use Symfony\Component\Serializer\DependencyInjection\AttributeMetadataPass as SerializerAttributeMetadataPass;
183172
use Symfony\Component\Serializer\Encoder\DecoderInterface;
184173
use Symfony\Component\Serializer\Encoder\EncoderInterface;
185174
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
@@ -205,9 +194,7 @@
205194
use Symfony\Component\Uid\UuidV4;
206195
use Symfony\Component\Validator\Constraint;
207196
use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider;
208-
use Symfony\Component\Validator\Constraints\Traverse;
209197
use Symfony\Component\Validator\ConstraintValidatorInterface;
210-
use Symfony\Component\Validator\DependencyInjection\AttributeMetadataPass as ValidatorAttributeMetadataPass;
211198
use Symfony\Component\Validator\GroupProviderInterface;
212199
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
213200
use Symfony\Component\Validator\ObjectInitializerInterface;
@@ -676,12 +663,6 @@ public function load(array $configs, ContainerBuilder $container): void
676663
->addTag('kernel.locale_aware');
677664
$container->registerForAutoconfiguration(ResetInterface::class)
678665
->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-
685666
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
686667
->addTag('property_info.list_extractor');
687668
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
@@ -843,10 +824,6 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
843824
{
844825
$loader->load('form.php');
845826

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

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

1009-
if (!$container->getParameter('kernel.debug') || !class_exists(CliRequest::class) || !$container->has('debug.stopwatch')) {
981+
if (!$container->getParameter('kernel.debug') || !$container->has('debug.stopwatch')) {
1010982
$container->removeDefinition('console_profiler_listener');
1011983
}
1012-
1013-
if (!class_exists(CommandDataCollector::class)) {
1014-
$container->removeDefinition('.data_collector.command');
1015-
}
1016984
}
1017985

1018986
private function registerWorkflowConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
@@ -1270,10 +1238,6 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
12701238

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

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

17671731
// When attributes are disabled, it means from runtime-discovery only; autoconfiguration should still happen.
17681732
// 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)) {
1733+
if (!($config['enable_attributes'] ?? false) || !$container->getParameter('kernel.debug')) {
17701734
// The $reflector argument hints at where the attribute could be used
17711735
$container->registerAttributeForAutoconfiguration(Constraint::class, function (ChildDefinition $definition, Constraint $attribute, \ReflectionClass|\ReflectionMethod|\ReflectionProperty $reflector) {
17721736
$definition->addTag('validator.attribute_metadata');
@@ -1818,9 +1782,6 @@ private function registerValidatorMapping(ContainerBuilder $container, array $co
18181782

18191783
if (!ContainerBuilder::willBeAvailable('symfony/form', Form::class, ['symfony/framework-bundle', 'symfony/validator'])) {
18201784
$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');
18241785
}
18251786

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

20171978
// When attributes are disabled, it means from runtime-discovery only; autoconfiguration should still happen.
20181979
// 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'))) {
1980+
if (!($config['enable_attributes'] ?? false) || !$container->getParameter('kernel.debug')) {
20201981
// The $reflector argument hints at where the attribute could be used
20211982
$configurator = function (ChildDefinition $definition, object $attribute, \ReflectionClass|\ReflectionMethod|\ReflectionProperty $reflector) {
20221983
$definition->addTag('serializer.attribute_metadata');
@@ -2037,15 +1998,10 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
20371998
});
20381999
}
20392000

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

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-
}
2003+
$container->getDefinition('serializer.mapping.attribute_loader')
2004+
->replaceArgument(0, $config['enable_attributes'] ?? false);
20492005

20502006
$fileRecorder = function ($extension, $path) use (&$serializerLoaders) {
20512007
$definition = new Definition(\in_array($extension, ['yaml', 'yml'], true) ? YamlFileLoader::class : XmlFileLoader::class, [$path]);
@@ -2289,11 +2245,6 @@ private function registerSchedulerConfiguration(ContainerBuilder $container, Php
22892245
if (!$this->hasConsole()) {
22902246
$container->removeDefinition('console.command.scheduler_debug');
22912247
}
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-
}
22972248
}
22982249

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

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

2359-
if ($lockEnabled && class_exists(DeduplicateMiddleware::class) && class_exists(LockFactory::class)) {
2306+
if ($lockEnabled && class_exists(LockFactory::class)) {
23602307
$defaultMiddleware['before'][] = ['id' => 'deduplicate_middleware'];
23612308
} else {
23622309
$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)