Skip to content

Commit 36e0d73

Browse files
Remove deprecated code paths
1 parent b01b78c commit 36e0d73

25 files changed

+53
-255
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ CHANGELOG
1111
* Remove the `lock.RESOURCE_NAME` and `lock.RESOURCE_NAME.store` services and the `lock`, `LockInterface`, `lock.store` and `PersistingStoreInterface` aliases, use `lock.RESOURCE_NAME.factory`, `lock.factory` or `LockFactory` instead
1212
* The `form.factory`, `form.type.file`, `translator`, `security.csrf.token_manager`, `serializer`,
1313
`cache_clearer`, `filesystem` and `validator` services are now private
14-
* Remove the `output-format` and `xliff-version` options from `TranslationUpdateCommand`
14+
* Remove the `output-format` and `xliff-version` options from `TranslationUpdateCommand`
15+
* Remove `has()`, `get()`, `getDoctrine()`n and `dispatchMessage()` from `AbstractController`, use method/constructor injection instead
16+
* Make the "framework.router.utf8" configuration option default to `true`
17+
* Remove the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
18+
* Make the `profiler` service private
19+
* Remove all other values than "none", "php_array" and "file" for `framework.annotation.cache`
20+
* Register workflow services as private
21+
* Remove support for passing a `RouteCollectionBuilder` to `MicroKernelTrait::configureRoutes()`, type-hint `RoutingConfigurator` instead
1522

1623
5.4
1724
---

Controller/AbstractController.php

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
use Symfony\Component\HttpFoundation\StreamedResponse;
3333
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
3434
use Symfony\Component\HttpKernel\HttpKernelInterface;
35-
use Symfony\Component\Messenger\Envelope;
3635
use Symfony\Component\Messenger\MessageBusInterface;
3736
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
3837
use Symfony\Component\Routing\RouterInterface;
@@ -104,32 +103,6 @@ public static function getSubscribedServices(): array
104103
];
105104
}
106105

107-
/**
108-
* Returns true if the service id is defined.
109-
*
110-
* @deprecated since Symfony 5.4, use method or constructor injection in your controller instead
111-
*/
112-
protected function has(string $id): bool
113-
{
114-
trigger_deprecation('symfony/framework-bundle', '5.4', 'Method "%s()" is deprecated, use method or constructor injection in your controller instead.', __METHOD__);
115-
116-
return $this->container->has($id);
117-
}
118-
119-
/**
120-
* Gets a container service by its id.
121-
*
122-
* @return object The service
123-
*
124-
* @deprecated since Symfony 5.4, use method or constructor injection in your controller instead
125-
*/
126-
protected function get(string $id): object
127-
{
128-
trigger_deprecation('symfony/framework-bundle', '5.4', 'Method "%s()" is deprecated, use method or constructor injection in your controller instead.', __METHOD__);
129-
130-
return $this->container->get($id);
131-
}
132-
133106
/**
134107
* Generates a URL from the given parameters.
135108
*
@@ -370,24 +343,6 @@ protected function createFormBuilder(mixed $data = null, array $options = []): F
370343
return $this->container->get('form.factory')->createBuilder(FormType::class, $data, $options);
371344
}
372345

373-
/**
374-
* Shortcut to return the Doctrine Registry service.
375-
*
376-
* @throws \LogicException If DoctrineBundle is not available
377-
*
378-
* @deprecated since Symfony 5.4, inject an instance of ManagerRegistry in your controller instead
379-
*/
380-
protected function getDoctrine(): ManagerRegistry
381-
{
382-
trigger_deprecation('symfony/framework-bundle', '5.4', 'Method "%s()" is deprecated, inject an instance of ManagerRegistry in your controller instead.', __METHOD__);
383-
384-
if (!$this->container->has('doctrine')) {
385-
throw new \LogicException('The DoctrineBundle is not registered in your application. Try running "composer require symfony/orm-pack".');
386-
}
387-
388-
return $this->container->get('doctrine');
389-
}
390-
391346
/**
392347
* Get a user from the Security Token Storage.
393348
*
@@ -423,25 +378,6 @@ protected function isCsrfTokenValid(string $id, ?string $token): bool
423378
return $this->container->get('security.csrf.token_manager')->isTokenValid(new CsrfToken($id, $token));
424379
}
425380

426-
/**
427-
* Dispatches a message to the bus.
428-
*
429-
* @param object|Envelope $message The message or the message pre-wrapped in an envelope
430-
*
431-
* @deprecated since Symfony 5.4, inject an instance of MessageBusInterface in your controller instead
432-
*/
433-
protected function dispatchMessage(object $message, array $stamps = []): Envelope
434-
{
435-
trigger_deprecation('symfony/framework-bundle', '5.4', 'Method "%s()" is deprecated, inject an instance of MessageBusInterface in your controller instead.', __METHOD__);
436-
437-
if (!$this->container->has('messenger.default_bus')) {
438-
$message = class_exists(Envelope::class) ? 'You need to define the "messenger.default_bus" configuration option.' : 'Try running "composer require symfony/messenger".';
439-
throw new \LogicException('The message bus is not enabled in your application. '.$message);
440-
}
441-
442-
return $this->container->get('messenger.default_bus')->dispatch($message, $stamps);
443-
}
444-
445381
/**
446382
* Adds a Link HTTP header to the current response.
447383
*

DependencyInjection/Compiler/TestServiceContainerWeakRefPass.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@
2222
*/
2323
class TestServiceContainerWeakRefPass implements CompilerPassInterface
2424
{
25-
private $privateTagName;
26-
27-
public function __construct(string $privateTagName = 'container.private')
28-
{
29-
if (0 < \func_num_args()) {
30-
trigger_deprecation('symfony/framework-bundle', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
31-
}
32-
33-
$this->privateTagName = $privateTagName;
34-
}
35-
3625
public function process(ContainerBuilder $container)
3726
{
3827
if (!$container->hasDefinition('test.private_services_locator')) {
@@ -44,7 +33,7 @@ public function process(ContainerBuilder $container)
4433
$hasErrors = method_exists(Definition::class, 'hasErrors') ? 'hasErrors' : 'getErrors';
4534

4635
foreach ($definitions as $id => $definition) {
47-
if ($id && '.' !== $id[0] && (!$definition->isPublic() || $definition->isPrivate() || $definition->hasTag($this->privateTagName)) && !$definition->$hasErrors() && !$definition->isAbstract()) {
36+
if ($id && '.' !== $id[0] && (!$definition->isPublic() || $definition->isPrivate() || $definition->hasTag('container.private')) && !$definition->$hasErrors() && !$definition->isAbstract()) {
4837
$privateServices[$id] = new Reference($id, ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE);
4938
}
5039
}

DependencyInjection/Configuration.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,8 @@ private function addFormSection(ArrayNodeDefinition $rootNode, callable $enableI
203203
->scalarNode('field_name')->defaultValue('_token')->end()
204204
->end()
205205
->end()
206-
// to be set to false in Symfony 6.0
207-
->booleanNode('legacy_error_messages')
208-
->defaultTrue()
209-
->validate()
210-
->ifTrue()
211-
->then(function ($v) {
212-
trigger_deprecation('symfony/framework-bundle', '5.2', 'Setting the "framework.form.legacy_error_messages" option to "true" is deprecated. It will have no effect as of Symfony 6.0.');
213-
214-
return $v;
215-
})
216-
->end()
217-
->end()
206+
// to be deprecated in Symfony 6.1
207+
->booleanNode('legacy_error_messages')->end()
218208
->end()
219209
->end()
220210
->end()
@@ -300,7 +290,6 @@ private function addProfilerSection(ArrayNodeDefinition $rootNode)
300290
->booleanNode('collect')->defaultTrue()->end()
301291
->booleanNode('only_exceptions')->defaultFalse()->end()
302292
->booleanNode('only_main_requests')->defaultFalse()->end()
303-
->booleanNode('only_master_requests')->setDeprecated('symfony/framework-bundle', '5.3', 'Option "%node%" at "%path%" is deprecated, use "only_main_requests" instead.')->defaultFalse()->end()
304293
->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end()
305294
->end()
306295
->end()
@@ -596,7 +585,7 @@ private function addRouterSection(ArrayNodeDefinition $rootNode)
596585
)
597586
->defaultTrue()
598587
->end()
599-
->booleanNode('utf8')->defaultNull()->end()
588+
->booleanNode('utf8')->defaultTrue()->end()
600589
->end()
601590
->end()
602591
->end()
@@ -950,7 +939,10 @@ private function addAnnotationsSection(ArrayNodeDefinition $rootNode, callable $
950939
->info('annotation configuration')
951940
->{$willBeAvailable('doctrine/annotations', Annotation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
952941
->children()
953-
->scalarNode('cache')->defaultValue(($doctrineCache || $psr6Cache) ? 'php_array' : 'none')->end()
942+
->enumNode('cache')
943+
->values(['none', 'php_array', 'file'])
944+
->defaultValue(($doctrineCache || $psr6Cache) ? 'php_array' : 'none')
945+
->end()
954946
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
955947
->booleanNode('debug')->defaultValue($this->debug)->end()
956948
->end()

DependencyInjection/FrameworkExtension.php

Lines changed: 22 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,6 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
603603
{
604604
$loader->load('form.php');
605605

606-
$container->getDefinition('form.type_extension.form.validator')->setArgument(1, $config['form']['legacy_error_messages']);
607-
608606
if (null === $config['form']['csrf_protection']['enabled']) {
609607
$config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled'];
610608
}
@@ -729,7 +727,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
729727
}
730728

731729
$container->setParameter('profiler_listener.only_exceptions', $config['only_exceptions']);
732-
$container->setParameter('profiler_listener.only_main_requests', $config['only_main_requests'] || $config['only_master_requests']);
730+
$container->setParameter('profiler_listener.only_main_requests', $config['only_main_requests']);
733731

734732
// Choose storage class based on the DSN
735733
[$class] = explode(':', $config['dsn'], 2);
@@ -992,10 +990,6 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
992990

993991
$loader->load('routing.php');
994992

995-
if (null === $config['utf8']) {
996-
trigger_deprecation('symfony/framework-bundle', '5.1', 'Not setting the "framework.router.utf8" configuration option is deprecated, it will default to "true" in version 6.0.');
997-
}
998-
999993
if ($config['utf8']) {
1000994
$container->getDefinition('routing.loader')->replaceArgument(1, ['utf8' => true]);
1001995
}
@@ -1530,61 +1524,36 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
15301524
return;
15311525
}
15321526

1533-
$cacheService = $config['cache'];
1534-
if (\in_array($config['cache'], ['php_array', 'file'])) {
1535-
$isPsr6Service = $container->hasDefinition('annotations.psr_cached_reader');
1536-
} else {
1537-
$isPsr6Service = false;
1538-
trigger_deprecation('symfony/framework-bundle', '5.3', 'Using a custom service for "framework.annotation.cache" is deprecated, only values "none", "php_array" and "file" are valid in version 6.0.');
1539-
}
1540-
1541-
if ($isPsr6Service) {
1542-
$container->removeDefinition('annotations.cached_reader');
1527+
if ($container->hasDefinition('annotations.psr_cached_reader')) {
15431528
$container->setDefinition('annotations.cached_reader', $container->getDefinition('annotations.psr_cached_reader'));
1529+
}
15441530

1545-
if ('php_array' === $config['cache']) {
1546-
$cacheService = 'annotations.cache_adapter';
1547-
1548-
// Enable warmer only if PHP array is used for cache
1549-
$definition = $container->findDefinition('annotations.cache_warmer');
1550-
$definition->addTag('kernel.cache_warmer');
1551-
} elseif ('file' === $config['cache']) {
1552-
$cacheService = 'annotations.filesystem_cache_adapter';
1553-
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
1554-
1555-
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
1556-
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
1557-
}
1531+
if ('php_array' === $config['cache']) {
1532+
$cacheService = $container->hasDefinition('annotations.psr_cached_reader') ? 'annotations.cache_adapter' : 'annotations.cache';
15581533

1559-
$container
1560-
->getDefinition('annotations.filesystem_cache_adapter')
1561-
->replaceArgument(2, $cacheDir)
1562-
;
1563-
}
1534+
// Enable warmer only if PHP array is used for cache
1535+
$definition = $container->findDefinition('annotations.cache_warmer');
1536+
$definition->addTag('kernel.cache_warmer');
15641537
} else {
1565-
// Legacy code for doctrine/annotations:<1.13
1566-
if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
1567-
throw new LogicException('Annotations cannot be cached as the Doctrine Cache library is not installed. Try running "composer require doctrine/cache".');
1568-
}
1538+
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
15691539

1570-
if ('php_array' === $config['cache']) {
1571-
$cacheService = 'annotations.cache';
1540+
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
1541+
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
1542+
}
15721543

1573-
// Enable warmer only if PHP array is used for cache
1574-
$definition = $container->findDefinition('annotations.cache_warmer');
1575-
$definition->addTag('kernel.cache_warmer');
1576-
} elseif ('file' === $config['cache']) {
1577-
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
1544+
$container
1545+
->getDefinition('annotations.filesystem_cache_adapter')
1546+
->replaceArgument(2, $cacheDir)
1547+
;
15781548

1579-
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
1580-
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
1549+
if ($container->hasDefinition('annotations.psr_cached_reader')) {
1550+
$cacheService = 'annotations.filesystem_cache_adapter';
1551+
} else {
1552+
// Legacy code for doctrine/annotations:<1.13
1553+
if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
1554+
throw new LogicException('Annotations cannot be cached as the Doctrine Cache library is not installed. Try running "composer require doctrine/cache".');
15811555
}
15821556

1583-
$container
1584-
->getDefinition('annotations.filesystem_cache_adapter')
1585-
->replaceArgument(2, $cacheDir)
1586-
;
1587-
15881557
$cacheService = 'annotations.filesystem_cache';
15891558
}
15901559
}
@@ -2297,9 +2266,6 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
22972266
$container->getDefinition('mailer.transports')->setArgument(0, $transports);
22982267
$container->getDefinition('mailer.default_transport')->setArgument(0, current($transports));
22992268

2300-
$container->removeDefinition('mailer.logger_message_listener');
2301-
$container->setAlias('mailer.logger_message_listener', (new Alias('mailer.message_logger_listener'))->setDeprecated('symfony/framework-bundle', '5.2', 'The "%alias_id%" alias is deprecated, use "mailer.message_logger_listener" instead.'));
2302-
23032269
$mailer = $container->getDefinition('mailer.mailer');
23042270
if (false === $messageBus = $config['message_bus']) {
23052271
$mailer->replaceArgument(1, null);

Resources/config/cache.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,6 @@
237237

238238
->alias(CacheItemPoolInterface::class, 'cache.app')
239239

240-
->alias(AdapterInterface::class, 'cache.app')
241-
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id%" alias is deprecated, use "%s" instead.', CacheItemPoolInterface::class)
242-
243240
->alias(CacheInterface::class, 'cache.app')
244241

245242
->alias(TagAwareCacheInterface::class, 'cache.app.taggable')

Resources/config/form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
->set('form.type_extension.form.validator', FormTypeValidatorExtension::class)
127127
->args([
128128
service('validator'),
129-
true,
129+
false,
130130
service('twig.form.renderer')->ignoreOnInvalid(),
131131
service('translator')->ignoreOnInvalid(),
132132
])

Resources/config/mailer.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@
6969
])
7070
->tag('kernel.event_subscriber')
7171

72-
->set('mailer.logger_message_listener', MessageLoggerListener::class)
73-
->tag('kernel.event_subscriber')
74-
->tag('kernel.reset', ['method' => 'reset'])
75-
->deprecate('symfony/framework-bundle', '5.2', 'The "%service_id%" service is deprecated, use "mailer.message_logger_listener" instead.')
76-
7772
->set('mailer.message_logger_listener', MessageLoggerListener::class)
7873
->tag('kernel.event_subscriber')
7974
->tag('kernel.reset', ['method' => 'reset'])

Test/KernelTestCase.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ abstract class KernelTestCase extends TestCase
3333
*/
3434
protected static $kernel;
3535

36-
/**
37-
* @var ContainerInterface
38-
*
39-
* @deprecated since Symfony 5.3, use static::getContainer() instead
40-
*/
41-
protected static $container;
42-
4336
protected static $booted = false;
4437

4538
private static $kernelContainer;
@@ -79,8 +72,7 @@ protected static function bootKernel(array $options = []): KernelInterface
7972
static::$kernel->boot();
8073
static::$booted = true;
8174

82-
self::$kernelContainer = $container = static::$kernel->getContainer();
83-
static::$container = $container->has('test.service_container') ? $container->get('test.service_container') : $container;
75+
self::$kernelContainer = static::$kernel->getContainer();
8476

8577
return static::$kernel;
8678
}
@@ -157,6 +149,6 @@ protected static function ensureKernelShutdown()
157149
self::$kernelContainer->reset();
158150
}
159151

160-
static::$container = self::$kernelContainer = null;
152+
self::$kernelContainer = null;
161153
}
162154
}

0 commit comments

Comments
 (0)