-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] fix definition and usage of AbstractArgument #36545
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
68dc521
to
03682ba
Compare
Thanks for simplifying this feature. This is the before: <service id="maker.generator" class="Symfony\Bundle\MakerBundle\Generator">
<argument type="service" id="maker.file_manager" />
<argument type="abstract" key="$rootNamespace">defined in MakerPass</argument>
</service> maker.generator:
class: Symfony\Bundle\MakerBundle\Generator
arguments:
$rootNamespace: !abstract defined in MakerPass $builder->register('maker.generator', Generator::class)
->addArgument(new AbstractArgument('maker.generator', '$rootNamespace', 'defined in MakerPass')); Could you please show the after config? Thanks! |
before: after: the rest is untouched. But the example in PHP should be this actually if we want the equivalent of yaml/xml: |
So I used this feature in the Security PR (see e.g. https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.xml#L17) as |
nope: we don't use named arguments in core
nothing changes here (but this is argument 3, not 1) |
Hmm, but then I think this feature might still not be generic enough (or at least, it doesn't fit Symfony's usage). If I read the code correctly, the XML currently used in Security will result in this error message: This is imho weird in 2 ways:
(Btw, I agree with the changes in this PR, but I feel like the feature itself is not 100% correct yet) |
The message would be: I get what you mean @wouterj, but I don't have any better proposal. |
Note that what matters is that the message is actionable. In this regard, I think it is. |
03682ba
to
abb463c
Compare
Updated to use positional numbers: |
@javiereguiluz Can you update the blog post? |
Thank you @nicolas-grekas. |
Yes! I've just updated the blog post 👍 |
Reading https://symfony.com/blog/new-in-symfony-5-1-abstract-service-arguments and the comments there made me realize that the current implementation is not generic enough. Abstract arguments can be found anywhere, not only as service arguments. Also,
AbstractArgument
instances should not convey the key/id since that makes them harder to use in the PHP-DSL.