Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 16fcdda

Browse filesBrowse files
[HttpKernel] remove deprecated features
1 parent 83de78c commit 16fcdda
Copy full SHA for 16fcdda

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

42 files changed

+73
-459
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function has(string $id): bool
106106
/**
107107
* {@inheritdoc}
108108
*/
109-
public function get(string $id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1): ?object
109+
public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE): ?object
110110
{
111111
return $this->getPrivateContainer()->has($id) ? $this->getPrivateContainer()->get($id) : $this->getPublicContainer()->get($id, $invalidBehavior);
112112
}

‎src/Symfony/Component/DependencyInjection/Container.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Container.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private function make(string $id, int $invalidBehavior)
240240
unset($this->loading[$id]);
241241
}
242242

243-
if (/* self::EXCEPTION_ON_INVALID_REFERENCE */ 1 === $invalidBehavior) {
243+
if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
244244
if (!$id) {
245245
throw new ServiceNotFoundException($id);
246246
}

‎src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,7 +1940,7 @@ private function getServiceCall(string $id, Reference $reference = null): string
19401940
return 'null';
19411941
}
19421942
if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $reference->getInvalidBehavior()) {
1943-
$code = sprintf('$this->get(%s, /* ContainerInterface::NULL_ON_INVALID_REFERENCE */ %d)', $this->doExport($id), ContainerInterface::NULL_ON_INVALID_REFERENCE);
1943+
$code = sprintf('$this->get(%s, ContainerInterface::NULL_ON_INVALID_REFERENCE)', $this->doExport($id));
19441944
} else {
19451945
$code = sprintf('$this->get(%s)', $this->doExport($id));
19461946
}

‎src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,8 @@
219219
<xsd:complexType name="deprecated">
220220
<xsd:simpleContent>
221221
<xsd:extension base="xsd:string">
222-
<!-- In Symfony 6, make these attributes required -->
223-
<xsd:attribute name="package" type="xsd:string" />
224-
<xsd:attribute name="version" type="xsd:string" />
222+
<xsd:attribute name="package" type="xsd:string" use="required" />
223+
<xsd:attribute name="version" type="xsd:string" use="required" />
225224
</xsd:extension>
226225
</xsd:simpleContent>
227226
</xsd:complexType>

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/deprecated_alias_definitions_without_package_and_version.xml

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/deprecated_alias_definitions_without_package_and_version.xml
-10Lines changed: 0 additions & 10 deletions
This file was deleted.

‎src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -466,16 +466,6 @@ public function testDeprecatedAliases()
466466
$this->assertSame($message, $container->getAlias('alias_for_foobar')->getDeprecation('alias_for_foobar')['message']);
467467
}
468468

469-
public function testDeprecatedAliaseWithoutPackageAndVersion()
470-
{
471-
$container = new ContainerBuilder();
472-
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
473-
474-
$this->expectException(InvalidArgumentException::class);
475-
$this->expectExceptionMessageMatches('/^Missing attribute "package" at node "deprecated" in "[^"]*".$/');
476-
$loader->load('deprecated_alias_definitions_without_package_and_version.xml');
477-
}
478-
479469
public function testConvertDomElementToArray()
480470
{
481471
$doc = new \DOMDocument('1.0');

‎src/Symfony/Component/HttpKernel/Attribute/ArgumentInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Attribute/ArgumentInterface.php
-23Lines changed: 0 additions & 23 deletions
This file was deleted.

‎src/Symfony/Component/HttpKernel/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/CHANGELOG.md
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* Remove `ArgumentInterface`
8+
* Remove `ArgumentMetadata::getAttribute()`, use `getAttributes()` instead
9+
* Remove support for returning a `ContainerBuilder` from `KernelInterface::registerContainerConfiguration()`
10+
* Remove `KernelEvent::isMasterRequest()`, use `isMainRequest()` instead
11+
* Remove support for `service:action` syntax to reference controllers, use `serviceOrFqcn::method` instead
12+
413
5.4
514
---
615

‎src/Symfony/Component/HttpKernel/Controller/ContainerControllerResolver.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Controller/ContainerControllerResolver.php
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ public function __construct(ContainerInterface $container, LoggerInterface $logg
3232
parent::__construct($logger);
3333
}
3434

35-
protected function createController(string $controller)
36-
{
37-
if (1 === substr_count($controller, ':')) {
38-
$controller = str_replace(':', '::', $controller);
39-
trigger_deprecation('symfony/http-kernel', '5.1', 'Referencing controllers with a single colon is deprecated. Use "%s" instead.', $controller);
40-
}
41-
42-
return parent::createController($controller);
43-
}
44-
4535
/**
4636
* {@inheritdoc}
4737
*/

‎src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php
+2-9Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,8 @@ public function getController(Request $request)
4848
try {
4949
$controller[0] = $this->instantiateController($controller[0]);
5050
} catch (\Error | \LogicException $e) {
51-
try {
52-
// We cannot just check is_callable but have to use reflection because a non-static method
53-
// can still be called statically in PHP but we don't want that. This is deprecated in PHP 7, so we
54-
// could simplify this with PHP 8.
55-
if ((new \ReflectionMethod($controller[0], $controller[1]))->isStatic()) {
56-
return $controller;
57-
}
58-
} catch (\ReflectionException $reflectionException) {
59-
throw $e;
51+
if (\is_callable($controller)) {
52+
return $controller;
6053
}
6154

6255
throw $e;

‎src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\HttpKernel\ControllerMetadata;
1313

14-
use Symfony\Component\HttpKernel\Attribute\ArgumentInterface;
15-
1614
/**
1715
* Responsible for storing metadata of an argument.
1816
*
@@ -114,20 +112,6 @@ public function getDefaultValue()
114112
return $this->defaultValue;
115113
}
116114

117-
/**
118-
* Returns the attribute (if any) that was set on the argument.
119-
*/
120-
public function getAttribute(): ?ArgumentInterface
121-
{
122-
trigger_deprecation('symfony/http-kernel', '5.3', 'Method "%s()" is deprecated, use "getAttributes()" instead.', __METHOD__);
123-
124-
if (!$this->attributes) {
125-
return null;
126-
}
127-
128-
return $this->attributes[0] instanceof ArgumentInterface ? $this->attributes[0] : null;
129-
}
130-
131115
/**
132116
* @return object[]
133117
*/

‎src/Symfony/Component/HttpKernel/DependencyInjection/ControllerArgumentValueResolverPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DependencyInjection/ControllerArgumentValueResolverPass.php
+5-20Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,25 @@ class ControllerArgumentValueResolverPass implements CompilerPassInterface
2828
{
2929
use PriorityTaggedServiceTrait;
3030

31-
private $argumentResolverService;
32-
private $argumentValueResolverTag;
33-
private $traceableResolverStopwatch;
34-
35-
public function __construct(string $argumentResolverService = 'argument_resolver', string $argumentValueResolverTag = 'controller.argument_value_resolver', string $traceableResolverStopwatch = 'debug.stopwatch')
36-
{
37-
if (0 < \func_num_args()) {
38-
trigger_deprecation('symfony/http-kernel', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
39-
}
40-
41-
$this->argumentResolverService = $argumentResolverService;
42-
$this->argumentValueResolverTag = $argumentValueResolverTag;
43-
$this->traceableResolverStopwatch = $traceableResolverStopwatch;
44-
}
45-
4631
public function process(ContainerBuilder $container)
4732
{
48-
if (!$container->hasDefinition($this->argumentResolverService)) {
33+
if (!$container->hasDefinition('argument_resolver')) {
4934
return;
5035
}
5136

52-
$resolvers = $this->findAndSortTaggedServices($this->argumentValueResolverTag, $container);
37+
$resolvers = $this->findAndSortTaggedServices('controller.argument_value_resolver', $container);
5338

54-
if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class) && $container->has($this->traceableResolverStopwatch)) {
39+
if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class) && $container->has('debug.stopwatch')) {
5540
foreach ($resolvers as $resolverReference) {
5641
$id = (string) $resolverReference;
5742
$container->register("debug.$id", TraceableValueResolver::class)
5843
->setDecoratedService($id)
59-
->setArguments([new Reference("debug.$id.inner"), new Reference($this->traceableResolverStopwatch)]);
44+
->setArguments([new Reference("debug.$id.inner"), new Reference('debug.stopwatch')]);
6045
}
6146
}
6247

6348
$container
64-
->getDefinition($this->argumentResolverService)
49+
->getDefinition('argument_resolver')
6550
->replaceArgument(1, new IteratorArgument($resolvers))
6651
;
6752
}

‎src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php
+3-16Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,15 @@
2525
*/
2626
class FragmentRendererPass implements CompilerPassInterface
2727
{
28-
private $handlerService;
29-
private $rendererTag;
30-
31-
public function __construct(string $handlerService = 'fragment.handler', string $rendererTag = 'kernel.fragment_renderer')
32-
{
33-
if (0 < \func_num_args()) {
34-
trigger_deprecation('symfony/http-kernel', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
35-
}
36-
37-
$this->handlerService = $handlerService;
38-
$this->rendererTag = $rendererTag;
39-
}
40-
4128
public function process(ContainerBuilder $container)
4229
{
43-
if (!$container->hasDefinition($this->handlerService)) {
30+
if (!$container->hasDefinition('fragment.handler')) {
4431
return;
4532
}
4633

47-
$definition = $container->getDefinition($this->handlerService);
34+
$definition = $container->getDefinition('fragment.handler');
4835
$renderers = [];
49-
foreach ($container->findTaggedServiceIds($this->rendererTag, true) as $id => $tags) {
36+
foreach ($container->findTaggedServiceIds('kernel.fragment_renderer', true) as $id => $tags) {
5037
$def = $container->getDefinition($id);
5138
$class = $container->getParameterBag()->resolveValue($def->getClass());
5239

‎src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php
+11-28Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,9 @@
3333
*/
3434
class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
3535
{
36-
private $resolverServiceId;
37-
private $controllerTag;
38-
private $controllerLocator;
39-
private $notTaggedControllerResolverServiceId;
40-
41-
public function __construct(string $resolverServiceId = 'argument_resolver.service', string $controllerTag = 'controller.service_arguments', string $controllerLocator = 'argument_resolver.controller_locator', string $notTaggedControllerResolverServiceId = 'argument_resolver.not_tagged_controller')
42-
{
43-
if (0 < \func_num_args()) {
44-
trigger_deprecation('symfony/http-kernel', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
45-
}
46-
47-
$this->resolverServiceId = $resolverServiceId;
48-
$this->controllerTag = $controllerTag;
49-
$this->controllerLocator = $controllerLocator;
50-
$this->notTaggedControllerResolverServiceId = $notTaggedControllerResolverServiceId;
51-
}
52-
5336
public function process(ContainerBuilder $container)
5437
{
55-
if (false === $container->hasDefinition($this->resolverServiceId) && false === $container->hasDefinition($this->notTaggedControllerResolverServiceId)) {
38+
if (!$container->hasDefinition('argument_resolver.service') && !$container->hasDefinition('argument_resolver.not_tagged_controller')) {
5639
return;
5740
}
5841

@@ -66,7 +49,7 @@ public function process(ContainerBuilder $container)
6649
}
6750
}
6851

69-
foreach ($container->findTaggedServiceIds($this->controllerTag, true) as $id => $tags) {
52+
foreach ($container->findTaggedServiceIds('controller.service_arguments', true) as $id => $tags) {
7053
$def = $container->getDefinition($id);
7154
$def->setPublic(true);
7255
$class = $def->getClass();
@@ -106,11 +89,11 @@ public function process(ContainerBuilder $container)
10689
}
10790
foreach (['action', 'argument', 'id'] as $k) {
10891
if (!isset($attributes[$k][0])) {
109-
throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "%s" %s for service "%s".', $k, $this->controllerTag, json_encode($attributes, \JSON_UNESCAPED_UNICODE), $id));
92+
throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "controller.service_arguments" %s for service "%s".', $k, json_encode($attributes, \JSON_UNESCAPED_UNICODE), $id));
11093
}
11194
}
11295
if (!isset($methods[$action = strtolower($attributes['action'])])) {
113-
throw new InvalidArgumentException(sprintf('Invalid "action" attribute on tag "%s" for service "%s": no public "%s()" method found on class "%s".', $this->controllerTag, $id, $attributes['action'], $class));
96+
throw new InvalidArgumentException(sprintf('Invalid "action" attribute on tag "controller.service_arguments" for service "%s": no public "%s()" method found on class "%s".', $id, $attributes['action'], $class));
11497
}
11598
[$r, $parameters] = $methods[$action];
11699
$found = false;
@@ -126,7 +109,7 @@ public function process(ContainerBuilder $container)
126109
}
127110

128111
if (!$found) {
129-
throw new InvalidArgumentException(sprintf('Invalid "%s" tag for service "%s": method "%s()" has no "%s" argument on class "%s".', $this->controllerTag, $id, $r->name, $attributes['argument'], $class));
112+
throw new InvalidArgumentException(sprintf('Invalid "controller.service_arguments" tag for service "%s": method "%s()" has no "%s" argument on class "%s".', $id, $r->name, $attributes['argument'], $class));
130113
}
131114
}
132115

@@ -145,7 +128,7 @@ public function process(ContainerBuilder $container)
145128
if ('?' !== $target[0]) {
146129
$invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE;
147130
} elseif ('' === $target = (string) substr($target, 1)) {
148-
throw new InvalidArgumentException(sprintf('A "%s" tag must have non-empty "id" attributes for service "%s".', $this->controllerTag, $id));
131+
throw new InvalidArgumentException(sprintf('A "controller.service_arguments" tag must have non-empty "id" attributes for service "%s".', $id));
149132
} elseif ($p->allowsNull() && !$p->isOptional()) {
150133
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
151134
}
@@ -205,16 +188,16 @@ public function process(ContainerBuilder $container)
205188

206189
$controllerLocatorRef = ServiceLocatorTagPass::register($container, $controllers);
207190

208-
if ($container->hasDefinition($this->resolverServiceId)) {
209-
$container->getDefinition($this->resolverServiceId)
191+
if ($container->hasDefinition('argument_resolver.service')) {
192+
$container->getDefinition('argument_resolver.service')
210193
->replaceArgument(0, $controllerLocatorRef);
211194
}
212195

213-
if ($container->hasDefinition($this->notTaggedControllerResolverServiceId)) {
214-
$container->getDefinition($this->notTaggedControllerResolverServiceId)
196+
if ($container->hasDefinition('argument_resolver.not_tagged_controller')) {
197+
$container->getDefinition('argument_resolver.not_tagged_controller')
215198
->replaceArgument(0, $controllerLocatorRef);
216199
}
217200

218-
$container->setAlias($this->controllerLocator, (string) $controllerLocatorRef);
201+
$container->setAlias('argument_resolver.controller_locator', (string) $controllerLocatorRef);
219202
}
220203
}

‎src/Symfony/Component/HttpKernel/DependencyInjection/RegisterLocaleAwareServicesPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DependencyInjection/RegisterLocaleAwareServicesPass.php
+4-17Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,26 @@
2323
*/
2424
class RegisterLocaleAwareServicesPass implements CompilerPassInterface
2525
{
26-
private $listenerServiceId;
27-
private $localeAwareTag;
28-
29-
public function __construct(string $listenerServiceId = 'locale_aware_listener', string $localeAwareTag = 'kernel.locale_aware')
30-
{
31-
if (0 < \func_num_args()) {
32-
trigger_deprecation('symfony/http-kernel', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
33-
}
34-
35-
$this->listenerServiceId = $listenerServiceId;
36-
$this->localeAwareTag = $localeAwareTag;
37-
}
38-
3926
public function process(ContainerBuilder $container)
4027
{
41-
if (!$container->hasDefinition($this->listenerServiceId)) {
28+
if (!$container->hasDefinition('locale_aware_listener')) {
4229
return;
4330
}
4431

4532
$services = [];
4633

47-
foreach ($container->findTaggedServiceIds($this->localeAwareTag) as $id => $tags) {
34+
foreach ($container->findTaggedServiceIds('kernel.locale_aware') as $id => $tags) {
4835
$services[] = new Reference($id);
4936
}
5037

5138
if (!$services) {
52-
$container->removeDefinition($this->listenerServiceId);
39+
$container->removeDefinition('locale_aware_listener');
5340

5441
return;
5542
}
5643

5744
$container
58-
->getDefinition($this->listenerServiceId)
45+
->getDefinition('locale_aware_listener')
5946
->setArgument(0, new IteratorArgument($services))
6047
;
6148
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.