-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Fix inlining conflict by restricting IteratorArgument to Reference[] #22496
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
518b1be
to
1991256
Compare
@@ -683,16 +684,19 @@ private function addService($id, Definition $definition) | |||
$code .= sprintf(" @trigger_error(%s, E_USER_DEPRECATED);\n\n", $this->export($definition->getDeprecationMessage($id))); | |||
} | |||
|
|||
$inlinedDefinitions = $this->getInlinedDefinitions($definition); |
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 replaces many calls to getInlinedDefinitions
by a single one
@@ -1332,8 +1336,6 @@ private function getDefinitionsFromArguments(array $arguments) | |||
foreach ($arguments as $argument) { | |||
if (is_array($argument)) { | |||
$definitions = array_merge($definitions, $this->getDefinitionsFromArguments($argument)); | |||
} elseif ($argument instanceof ArgumentInterface) { | |||
$definitions = array_merge($definitions, $this->getDefinitionsFromArguments($argument->getValues())); |
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 a bug, silent for now because we don't have inline definitions in $argument->getValues()
, but still a logical mistake
@@ -1452,6 +1454,9 @@ private function dumpValue($value, $interpolate = true) | |||
if ($value->getMethodCalls()) { | |||
throw new RuntimeException('Cannot dump definitions which have method calls.'); | |||
} | |||
if ($value->getProperties()) { |
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 be done on 2.7 also
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.
then please split it in a separate PR
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.
done in #22498
@@ -1452,6 +1454,9 @@ private function dumpValue($value, $interpolate = true) | |||
if ($value->getMethodCalls()) { | |||
throw new RuntimeException('Cannot dump definitions which have method calls.'); | |||
} | |||
if ($value->getProperties()) { |
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.
then please split it in a separate PR
} | ||
|
||
return new IteratorArgument($this->resolveServices($argument, $file, $isParameter)); | ||
try { | ||
return new IteratorArgument($this->resolveServices($argument, $file, $isParameter)); |
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.
IMO, resolveServices
should be outside the try/catch, so that we don't replace its exceptions by mistake
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.
good idea, done (also for the Xml loader, just in case)
15f9711
to
a67c3d7
Compare
a67c3d7
to
4d3dce1
Compare
try { | ||
$arguments[$key] = new IteratorArgument($arg); | ||
} catch (InvalidArgumentException $e) { | ||
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="iterator" only accepts collections of type="service" references.', $name)); |
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.
Tag
=> Argument
? Attribute
?
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.
It's an xml tag, eg Tag "<argument>" ...
or Tag "<property>" ...
Thank you @nicolas-grekas. |
… to Reference[] (nicolas-grekas) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] Fix inlining conflict by restricting IteratorArgument to Reference[] | 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 | - `Reference` found in `ArgumentInterface::getValue()` are currently not inlined. While trying to do so (hint: I failed), I noticed that the current code is broken for `IteratorArgument` which can contain anonymous `Definition` for now, which are then not inlined correctly. This PR restricts `IteratorArgument` to arrays of `Reference`, and improves a few related things found while doing it. (fabbot failure is false positive) Commits ------- 4d3dce1 [DI] Fix inlining conflict by restricting IteratorArgument to Reference[]
Reference
found inArgumentInterface::getValue()
are currently not inlined.While trying to do so (hint: I failed), I noticed that the current code is broken for
IteratorArgument
which can contain anonymousDefinition
for now, which are then not inlined correctly.This PR restricts
IteratorArgument
to arrays ofReference
, and improves a few related things found while doing it.(fabbot failure is false positive)