Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 091f943

Browse filesBrowse files
[DI] Fix tracking of bound arguments when using autoconfiguration
1 parent f617882 commit 091f943
Copy full SHA for 091f943

File tree

Expand file treeCollapse file tree

3 files changed

+9
-6
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+9
-6
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php
+3Lines 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())

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ParentTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ParentTrait.php
+2Lines 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);

‎src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1515
use Symfony\Component\DependencyInjection\ChildDefinition;
1616
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17-
use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass;
1817
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
1918
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
2019
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -54,11 +53,13 @@ public function process(ContainerBuilder $container)
5453
$def->setPublic(true);
5554
$class = $def->getClass();
5655
$autowire = $def->isAutowired();
56+
$bindings = $def->getBindings();
5757

5858
// resolve service class, taking parent definitions into account
59-
while (!$class && $def instanceof ChildDefinition) {
59+
while ($def instanceof ChildDefinition) {
6060
$def = $container->findDefinition($def->getParent());
61-
$class = $def->getClass();
61+
$class = $class ?: $def->getClass();
62+
$bindings = $def->getBindings();
6263
}
6364
$class = $parameterBag->resolveValue($class);
6465

@@ -111,9 +112,6 @@ public function process(ContainerBuilder $container)
111112
}
112113
}
113114

114-
// not validated, they are later in ResolveBindingsPass
115-
$bindings = $def->getBindings();
116-
117115
foreach ($methods as list($r, $parameters)) {
118116
/** @var \ReflectionMethod $r */
119117

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.