-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[DI] Fix invalid callables dumped for ArgumentInterface objects #22581
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
6b19730
to
e42a23d
Compare
Diff best reviewed ignoring whitespaces: https://github.com/symfony/symfony/pull/22581/files?w=1 |
} elseif ($value instanceof ServiceClosureArgument) { | ||
$value = $value->getValues()[0]; | ||
$code = $this->dumpValue($value, $interpolate); | ||
} elseif ($scope = $value instanceof ArgumentInterface) { |
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.
should just be if
as the previous if returns
$value = $value->getValues()[0]; | ||
$code = $this->dumpValue($value, $interpolate); | ||
} elseif ($scope = $value instanceof ArgumentInterface) { | ||
$scope = array($this->definitionVariables, $this->referenceVariables, $this->variableCount); |
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.
Reusing the same variable to store a boolean or an array is harder to follow. Can't we put the try/finally
inside this if instead, which will allow to only store an array in $scope
?
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.
fixed, PR should be OK
e42a23d
to
ff825e9
Compare
ff825e9
to
f81c577
Compare
Thank you @iltar. |
…jects (nicolas-grekas, iltar) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] Fix invalid callables dumped for ArgumentInterface objects | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Follow up of #22511, from @iltar: > Currently, when having a service definition which has more than 1 usage of that service, it will put the argument in `$a` for example. By doing so, it will also use `$a` in the callable of the `ServiceLocator`, which result in an undefined variable `$a`. > I managed to trigger this with the translator service, where I have my own loader, that I add for NL and EN, causing 2 method calls to turn the direct getter into a variable. I've added 2 test cases, 1 with only 1 method call and 1 with 2 method calls. Commits ------- f81c577 [DI] Test references inside ServiceLocator are not inlined 8783602 [DI] Fix invalid callables dumped for ArgumentInterface objects
Follow up of #22511, from @iltar: