-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Add #[WhenNot]
attribute
#57379
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
3a5ae9b
to
4726065
Compare
src/Symfony/Component/DependencyInjection/Loader/FileLoader.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/NotFoo.php
Outdated
Show resolved
Hide resolved
c9521d9
to
88e7ee5
Compare
Tests added on both attribute on classes and functions. |
88e7ee5
to
7e792dd
Compare
What about |
7e792dd
to
558f21b
Compare
#[NotWhen]
attribute#[WhenNot]
attribute
558f21b
to
a3a5c9b
Compare
I kind of find it hard to understand at first glance personally. I'm afraid it gives "yoga style" kind of confusion when reading it. |
src/Symfony/Component/DependencyInjection/Loader/FileLoader.php
Outdated
Show resolved
Hide resolved
What's the status of this PR? |
a3a5c9b
to
eb29479
Compare
Status: Needs Review I still think that would be a nice addition for DX 👍 |
eb29479
to
208fd12
Compare
208fd12
to
f91acad
Compare
src/Symfony/Component/DependencyInjection/Loader/FileLoader.php
Outdated
Show resolved
Hide resolved
f91acad
to
7349e3f
Compare
Thank you @alexandre-daubois. |
When dealing with many environment and concrete+test implementations of many services, it can be tricky/verbose to repeat
#[When]
for each and every existing env. By using#[NotWhen]
, it becomes handy to deal with different implementations of a service across different env:It also eases the creation of a new env: no more need to go across all
#[When]
occurrences to update service definitions.You cannot use When and NotWhen at the same time: