-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Add "factory" support to named args and autowiring #22277
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
2ca4e9d
to
cf8ddbc
Compare
* @param Definition $definition | ||
* @param bool $required | ||
* | ||
* @return \ReflectionFunctionAbstract |
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.
|null
?
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.
yup, fixed
cf8ddbc
to
27470de
Compare
} elseif (null === $class) { | ||
$class = $definition->getClass(); | ||
} | ||
if ('__construct' === $method) { |
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.
Does it really belong to this method? Shouldn't it be in CheckDefinitionValidityPass
instead?
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.
this is required to prevent a potential infinite loop
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.
Ok, good point too :) It should still be added in CheckDefinitionValidityPass
imo though.
if ($constructor = $reflectionClass->getConstructor()) { | ||
array_unshift($methodCalls, array($constructor->name, $value->getArguments())); | ||
if ($constructor = $this->getConstructor($value, false)) { | ||
array_unshift($methodCalls, array($constructor, $value->getArguments())); |
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.
Can't we keep ->name
to remove the dedicated case, line 183 (https://github.com/symfony/symfony/pull/22277/files#diff-62df969ae028c559d33ffd256de1ac49R183)?
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.
nope we can't, because when a factory is used, a simple string is not enough to reference the target
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.
Ok, good point 👍
Thank you @nicolas-grekas. |
…g (nicolas-grekas) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] Add "factory" support to named args and autowiring | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - To me, factories are expected to work named arguments. Doing so also unlocks supporting them when autowiring, and will benefit #22187 soon. Commits ------- 27470de [DI] Add "factory" support to named args and autowiring
To me, factories are expected to work named arguments.
Doing so also unlocks supporting them when autowiring, and will benefit #22187 soon.