Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] Remove deprecated ContainerBuilder::getAutoconfiguredAttributes() #60844

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
Jun 20, 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: 2 additions & 0 deletions UPGRADE-8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ DependencyInjection
}
```

* 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 @@ -5,6 +5,7 @@ CHANGELOG
---

* Remove `#[TaggedIterator]` and `#[TaggedLocator]` attributes, replaced by `#[AutowireLocator]` and `#[AutowireIterator]`
* Remove `ContainerBuilder::getAutoconfiguredAttributes()`, replaced by `ContainerBuilder::getAttributeAutoconfigurators()`

7.4
---
Expand Down
21 changes: 0 additions & 21 deletions src/Symfony/Component/DependencyInjection/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1488,27 +1488,6 @@ public function getAutoconfiguredInstanceof(): array
return $this->autoconfiguredInstanceof;
}

/**
* @return array<class-string, callable>
*
* @deprecated Use {@see getAttributeAutoconfigurators()} instead
*/
public function getAutoconfiguredAttributes(): array
{
trigger_deprecation('symfony/dependency-injection', '7.3', 'The "%s()" method is deprecated, use "getAttributeAutoconfigurators()" instead.', __METHOD__);

$autoconfiguredAttributes = [];
foreach ($this->autoconfiguredAttributes as $attribute => $configurators) {
if (count($configurators) > 1) {
throw new LogicException(\sprintf('The "%s" attribute has %d configurators. Use "getAttributeAutoconfigurators()" to get all of them.', $attribute, count($configurators)));
}

$autoconfiguredAttributes[$attribute] = $configurators[0];
}

return $autoconfiguredAttributes;
}

/**
* @return array<class-string, callable[]>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -842,25 +842,6 @@ public function testMergeAttributeAutoconfiguration()
$this->assertSame([AsTaggedItem::class => [$c1, $c2]], $container->getAttributeAutoconfigurators());
}

/**
* @group legacy
*/
public function testGetAutoconfiguredAttributes()
{
$container = new ContainerBuilder();
$container->registerAttributeForAutoconfiguration(AsTaggedItem::class, $c = static function () {});

$this->expectUserDeprecationMessage('Since symfony/dependency-injection 7.3: The "Symfony\Component\DependencyInjection\ContainerBuilder::getAutoconfiguredAttributes()" method is deprecated, use "getAttributeAutoconfigurators()" instead.');
$configurators = $container->getAutoconfiguredAttributes();
$this->assertSame($c, $configurators[AsTaggedItem::class]);

// Method call fails with more than one configurator for a given attribute
$container->registerAttributeForAutoconfiguration(AsTaggedItem::class, $c = static function () {});

$this->expectException(LogicException::class);
$container->getAutoconfiguredAttributes();
}

public function testResolveEnvValues()
{
$_ENV['DUMMY_ENV_VAR'] = 'du%%y';
Expand Down
Loading