-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Expose tags as consts for PHP config autocompletion #24377
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
Cool, I had that on my list :) |
Done. Do you like segregation by components, like introduced in the second commit ? vs |
I'm 👎. I understand the goal, but that introduces another "name" for each tag. The current are well documented everywhere. Not sure if this is worth it. |
@fabpot how about following the Events model: each bundle/component that introduces a new tag needs to add a new constant into a Tags class at the root of the bundle/component. |
@afurculita: FI, that was the first version of this PR: ogizanagi@7a27b6b |
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 think this is a great DX improvement, as it allows autocompletion and far easier discovery.
I don't know if that'd be enough to convince fabpot, but I'd suggest the following changes:
- stick to providing the consts for the purpose of the DSL only. Ie not use them anywhere internally.
- use a CS convention to name consts that follows the tag name as closely as possible, eg dot=namespace, all the rest stays the same, case included.
In my local stash, I also started adding docblocks on the consts, as I believe that's a great place to have some words about what behavior each tag provides. Being able to have that info directly in a click in my IDE would be another great DX improvement that this would provide.
To empty my stash, here is what I had: <?php
namespace Symfony\Component\DependencyInjection\Loader\Configurator\tag;
/**
* Define aliases based on the value of container parameters.
*
* The required "format" attribute defines the service to alias and can use any container parameter.
*
* You need to manually add the AutoAliasServicePass compiler pass to the container for this feature to work.
*/
const auto_alias = 'auto_alias';
namespace Symfony\Component\DependencyInjection\Loader\Configurator\tag\container;
/**
* Enable services implementing the ServiceSubscriberInterface to have their service locator created automatically.
*
* The optional "key" and "id" attributes allow setting entries to the created service locator.
* You can repeat this tag several times to set "key"/"id" pairs on the locator.
*/
const service_subscriber = 'container.service_subscriber'; |
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
Of course, I'll update the PR to include those if we can convince @fabpot :) |
The doc blocks could also be the place where we tell about which interface adds the tag by mean of autoconfiguration (when applicable.) |
Moving to 4.1. |
I'm closing because this is staling and controversial for now. Let's re-open later if we want. |
Now that we have PHP based-config, it'll make sense to have tags exposed as constants for autocompletion & discoverability.
Consts are are defined in the bundles for discoverability and because that's where passes are configured.