-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Deprecate #[TaggedIterator]
and #[TaggedLocator]
#54371
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
Conversation
#[TaggedIterator]
and #[TaggedLocator]
#[TaggedIterator]
and #[TaggedLocator]
#[TaggedIterator]
and #[TaggedLocator]
#[TaggedIterator]
and #[TaggedLocator]
Tests covering those 2 attributes must be updated to be marked as |
65d3a3a
to
437bf87
Compare
src/Symfony/Component/DependencyInjection/Tests/Fixtures/MultipleArgumentBindings.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tests updated. I think the CI errors are not related to this change.
src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterServiceSubscribersPassTest.php
Outdated
Show resolved
Hide resolved
$this->assertTrue($locator->has('locator1')); | ||
$this->assertInstanceOf(ServiceLocator::class, $argLocator = $locator->get('locator1')); | ||
$this->assertCount(2, $argLocator); | ||
$this->assertTrue($argLocator->has('bar')); | ||
$this->assertTrue($argLocator->has('baz')); | ||
|
||
$this->assertSame(iterator_to_array($argIterator), [$argLocator->get('bar'), $argLocator->get('baz')]); | ||
} | ||
|
||
public function testAutowireIteratorAndAutowireLocatorAttributes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've split the test in legacy and new attributes. There is no expectDeprecation
so the test passes with symfony/dependency-injection 7.0
src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php
Show resolved
Hide resolved
Should this be more general... i fear this could feel a bit of a half seated DX too, with return function (ContainerConfigurator $container): void {
$services->set(Two::class)
->tag('app.handler', ['key' => 'handler_two']);
$services->set(App\HandlerCollection::class)
->args([
// 2nd argument is the index attribute name
tagged_iterator('app.handler', 'key'),
])
;
}; Versus class HandlerCollection
{
public function __construct(
#[AutowireIterator('app.handler', indexAttribute: 'key')]
iterable $handlers
) {
}
}
// ...
#[AsTaggedItem(index: 'handler_one', priority: 10)]
class One
{
// ...
} |
You mean But In terms of DX, we currently have 2 attributes that does the exact same thing. |
I totally understand your motive here :) What i feel is a lack of consistency / predictability here, that could be difficult to explain / document / etc.
So maybe we could rename
|
The name |
...omponent/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php
Outdated
Show resolved
Hide resolved
8514c76
to
aa85bd4
Compare
aa85bd4
to
4bc6bed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this.
We cannot use the term "autowire" when doing explicit config so keeping tagged_iterator for the config is legit.
What would be best regarding naming is having AutowireTaggedIterator. BUT, this feels like overhead.
Thank you @GromNaN. |
…#[TaggedLocator]` attributes (GromNaN) This PR was merged into the 8.0 branch. Discussion ---------- [DependencyInjection] Remove `#[TaggedIterator]` and `#[TaggedLocator]` attributes | Q | A | ------------- | --- | Branch? | 8.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | - | License | MIT The new attributes `#[AutowireLocator]` and `#[AutowireIterator]` were introduced in Symfony 6.4 by #51392 and #51832. These replace the previous attributes `#[TaggedIterator]` and `#[TaggedLocator]` which were introduced in Symfony 5.4 by #40406 and subsequently deprecated in 7.1 by #54371 Commits ------- c096714 Remove TaggedIterator and TaggedLocator attributes
#[TaggedIterator]
and#[TaggedLocator]
attributes are replaced by#[AutowireIterator]
and#[AutowireLocator]
, for naming consistency with all#[Autowire*]
attributes.