-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] The class of a service definition might be passed as parameter #32279
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
2ebd755
to
af42a0f
Compare
This looks wrong to me. The usage should be |
That is not the same semantics: |
I'm wondering if we shouldn't reject this PR, and deprecate passing a Parameter instead. This looks like something that is not needed to me. |
That would certainly improve the maintainability of the class. Shall I open a PR? |
yes please! |
Closing as I agree that this "use case" should be deprecated instead. |
New PR: #32390 |
…tances as class name to Definition (derrabus) This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Deprecated passing Parameter instances as class name to Definition | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #32279 | License | MIT | Doc PR | N/A This PR deprecates the undocumented possibility to use a `Parameter` instance instead of a string as class name for a `Definition`. This was discovered while working on #32266. Commits ------- edfc9d6 Deprecated passing Parameter instances as class name to Definition.
While working on #32266, I discovered that we can pass an instance of
Parameter
as$class
to aDefinition
, although the docblock saysstring|null
.symfony/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
Line 931 in 6eeec65
I'd like to adjust the docblock, so nobody will ever be tempted to add a type-hint to
setClass()
again. 😉I've also added a test because the test failure that I got wasn't really obviously pointing at the problem.