Skip to content

Commit 7caa728

Browse files
bug #24313 [DI] Fix tracking of bound arguments when using autoconfiguration (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [DI] Fix tracking of bound arguments when using autoconfiguration | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - An exception is currently thrown when using arguments bindings on an autoconfigured controller action. This fixes the issue. Commits ------- 091f943 [DI] Fix tracking of bound arguments when using autoconfiguration
2 parents 1071f62 + 3c07fff commit 7caa728

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Compiler/ResolveInstanceofConditionalsPass.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ private function processDefinition(ContainerBuilder $container, $id, Definition
9090
}
9191

9292
if ($parent) {
93+
$bindings = $definition->getBindings();
9394
$abstract = $container->setDefinition('abstract.instanceof.'.$id, $definition);
9495

9596
// cast Definition to ChildDefinition
97+
$definition->setBindings(array());
9698
$definition = serialize($definition);
9799
$definition = substr_replace($definition, '53', 2, 2);
98100
$definition = substr_replace($definition, 'Child', 44, 0);
@@ -117,6 +119,7 @@ private function processDefinition(ContainerBuilder $container, $id, Definition
117119

118120
// reset fields with "merge" behavior
119121
$abstract
122+
->setBindings($bindings)
120123
->setArguments(array())
121124
->setMethodCalls(array())
122125
->setTags(array())

Loader/Configurator/Traits/ParentTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ final protected function setParent($parent)
3838
$this->definition->setParent($parent);
3939
} elseif ($this->definition->isAutoconfigured()) {
4040
throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also have "autoconfigure". Try disabling autoconfiguration for the service.', $this->id));
41+
} elseif ($this->definition->getBindings()) {
42+
throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also "bind" arguments.', $this->id));
4143
} else {
4244
// cast Definition to ChildDefinition
4345
$definition = serialize($this->definition);

0 commit comments

Comments
 (0)