-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC] Normalize root namespaces with DI #28006
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
Comments
root class named services are supported. What is not supported for them is the shortcut allowing to guess the class name from the id. |
Correct. My reasoning is, if |
👎 on my side: there should be only one valid id. Normalization creates alternative ways and leads to issues. We deprecated lowercasing for this reason. |
So yes, a leading For the |
But if there are no technical reasons, deprecating for the sake of it is not worth it IMHO. |
Fair, that's why I opened the RFC. You're right, it's purely a DX issue. No technical reason. In a way this error is just a weird side effect:
Nevertheless, we can settle by qualifying it a doc issue. Then i'll go back to symfony/symfony-docs#8403 :) |
Sure, it's always worth asking, and that's just my 2cts :) |
@ro0NL thanks for starting this discussion. I disagree about "polluting" the Symfony Docs with these minor details. This can be solved with a great error message generated by Symfony when this happens. The current error message is good, but I'd like to propose a minor reword to make it more clear what the developer must do to solve it:
|
This PR was squashed before being merged into the 3.4 branch (closes #28057). Discussion ---------- [DI] Improve class named servics error message | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #28006 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Commits ------- 61de060 [DI] Improve class named servics error message
Uh oh!
There was an error while loading. Please reload this page.
Description
For context see: symfony/symfony-docs#8403 and #24145
Currently only namespaced classes are detected as "class named services", i.e.
I propose to deprecate leading slashes in service ids. So you most likely end up with the working/last example in the future.
In case a class lives in the root namespace (first example) you'd get the error about a missing class attribute which we can easily explain: "root class named services" are not supported. Hence you must specify the class attribute. Which brings me to the next point;
Currently it's allowed to use both
class: MyClass
andclass: \MyClass
which causes some form of inconsistency, and makes$def->getClass() === MyClass::class
error prone.I propose to normalize leading slashes in a service its class attribute. Although i tend to prefer a deprecation here as well.
Thoughts?
The text was updated successfully, but these errors were encountered: