Skip to content

[DependencyInjection] Remove !tagged tag, use !tagged_iterator instead #61179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UPGRADE-8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ DependencyInjection
public function __construct(#[AutowireIterator('app.my_tag')] private iterable $services) {}
}
```

* Remove `!tagged` tag, use `!tagged_iterator` instead
* Remove the `ContainerBuilder::getAutoconfiguredAttributes()` method, use `getAttributeAutoconfigurators()` instead to retrieve all the callbacks for a specific attribute class

DoctrineBridge
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CHANGELOG

* Remove `#[TaggedIterator]` and `#[TaggedLocator]` attributes, replaced by `#[AutowireLocator]` and `#[AutowireIterator]`
* Remove `ContainerBuilder::getAutoconfiguredAttributes()`, replaced by `ContainerBuilder::getAttributeAutoconfigurators()`
* Remove `!tagged` tag, use `!tagged_iterator` instead

7.4
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,6 @@ private function getArgumentsAsPhp(\DOMElement $node, string $name, string $file
$arg = $this->getArgumentsAsPhp($arg, $name, $file);
$arguments[$key] = new ServiceLocatorArgument($arg);
break;
case 'tagged':
trigger_deprecation('symfony/dependency-injection', '7.2', 'Type "tagged" is deprecated for tag <%s>, use "tagged_iterator" instead in "%s".', $name, $file);
// no break
case 'tagged_iterator':
case 'tagged_locator':
$forLocator = 'tagged_locator' === $type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,7 @@ private function resolveServices(mixed $value, string $file, bool $isParameter =

return new ServiceLocatorArgument($argument);
}
if (\in_array($value->getTag(), ['tagged', 'tagged_iterator', 'tagged_locator'], true)) {
if ('tagged' === $value->getTag()) {
trigger_deprecation('symfony/dependency-injection', '7.2', 'Using "!tagged" is deprecated, use "!tagged_iterator" instead in "%s".', $file);
}

if (\in_array($value->getTag(), ['tagged_iterator', 'tagged_locator'], true)) {
$forLocator = 'tagged_locator' === $value->getTag();

if (\is_array($argument) && isset($argument['tag']) && $argument['tag']) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1335,19 +1335,6 @@ public function testUnknownConstantAsKey()
$loader->load('key_type_wrong_constant.xml');
}

/**
* @group legacy
*/
public function testDeprecatedTagged()
{
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));

$this->expectUserDeprecationMessage(\sprintf('Since symfony/dependency-injection 7.2: Type "tagged" is deprecated for tag <argument>, use "tagged_iterator" instead in "%s/xml%sservices_with_deprecated_tagged.xml".', self::$fixturesPath, \DIRECTORY_SEPARATOR));

$loader->load('services_with_deprecated_tagged.xml');
}

public function testLoadServicesWithEnvironment()
{
$container = new ContainerBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1211,17 +1211,4 @@ public function testStaticConstructor()
$definition = $container->getDefinition('static_constructor');
$this->assertEquals((new Definition('stdClass'))->setFactory([null, 'create']), $definition);
}

/**
* @group legacy
*/
public function testDeprecatedTagged()
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));

$this->expectUserDeprecationMessage(\sprintf('Since symfony/dependency-injection 7.2: Using "!tagged" is deprecated, use "!tagged_iterator" instead in "%s/yaml%stagged_deprecated.yml".', self::$fixturesPath, \DIRECTORY_SEPARATOR));

$loader->load('tagged_deprecated.yml');
}
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy