-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Exclude inline services declared in XML from autowiring candidates #24491
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
3bef6b3
to
d90e721
Compare
@@ -345,7 +345,7 @@ private function populateAvailableType($id, Definition $definition) | |||
unset($this->ambiguousServiceTypes[$type]); | |||
} | |||
|
|||
if ($definition->isDeprecated() || !$reflectionClass = $this->container->getReflectionClass($definition->getClass(), false)) { | |||
if (preg_match('/^\d+_[^~]++~[._a-zA-Z\d]{7}$/', $id) || $definition->isDeprecated() || !$reflectionClass = $this->container->getReflectionClass($definition->getClass(), false)) { |
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.
Do we have such a regex somewhere else? Would it make sense to store it as a reusable const somewhere?
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.
That's internal to me: I added an integration test ensuring we don't rely on this exact detail, but on the actual behavior. Thus, not sure a const is needed.
Thank you @nicolas-grekas. |
…ng candidates (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [DI] Exclude inline services declared in XML from autowiring candidates | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24311 | License | MIT | Doc PR | - As reported in #24311, inline services should not be candidates for autowiring. This PR fixes the issue, but is submitted against 3.4 because there is a potential BC break here, for ppl that didn't realize they relied on this (already deprecated) behavior. We *could* not merge this PR and consider the deprecation is fine - but in practice, the WTF is hitting several ppl already AFAIK, so we should close that door IMHO. Commits ------- d90e721 [DI] Exclude inline services declared in XML from autowiring candidates
As reported in #24311, inline services should not be candidates for autowiring.
This PR fixes the issue, but is submitted against 3.4 because there is a potential BC break here, for ppl that didn't realize they relied on this (already deprecated) behavior.
We could not merge this PR and consider the deprecation is fine - but in practice, the WTF is hitting several ppl already AFAIK, so we should close that door IMHO.