Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] Resolve ChildDefinition in AbstractRecursivePass #44418

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

Merged
merged 1 commit into from
Dec 11, 2021

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Dec 2, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets #44342
License MIT
Doc PR -

At least AttributeAutoconfigurationPass (5.4 new pass) relies on AbstractRecursivePass and is executed before ResolveChildDefinitionsPass so child definitions are not necessary resolved in AbstractRecursivePass. Doing it on 4.4 to have the same behavior on all maintained branches.

It fixes #44342 in a better way because the final class of the factory can be resolved.

@@ -131,25 +132,35 @@ protected function getConstructor(Definition $definition, $required)

if ($factory) {
[$class, $method] = $factory;

if ('__construct' === $method) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's throw as soon as possible?


try {
if (!$r = $this->container->getReflectionClass($class)) {
if (null === $class) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a minor DX improvement. If the class is null this message looks better to me than Invalid service "foo": class "" does not exist. (see getReflectionMethod() below where we already check if a class is set or not).

@fancyweb fancyweb force-pushed the di/resolve-factory-parent-abrp branch from 86febb1 to acbee81 Compare December 11, 2021 14:54
@nicolas-grekas
Copy link
Member

Thank you @fancyweb.

@nicolas-grekas nicolas-grekas merged commit 67f7917 into symfony:4.4 Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants