Skip to content

Commit 24b29d9

Browse files
committed
Fixes
1 parent 316b818 commit 24b29d9

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
final class BoundArgument implements ArgumentInterface
1818
{
19-
private static $count = 0;
19+
private static $sequence = 0;
2020

2121
private $value;
2222
private $identifier;
@@ -25,7 +25,7 @@ final class BoundArgument implements ArgumentInterface
2525
public function __construct($value)
2626
{
2727
$this->value = $value;
28-
$this->identifier = ++self::$count;
28+
$this->identifier = ++self::$sequence;
2929
}
3030

3131
/**

src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ protected function processValue($value, $isRoot = false)
6969
}
7070

7171
foreach ($parameters as $j => $p) {
72-
$typeHint = ProxyHelper::getTypeHint($r, $p, true);
73-
74-
if ($typeHint === $key) {
72+
if (ProxyHelper::getTypeHint($r, $p, true) === $key) {
7573
$resolvedArguments[$j] = $argument;
7674

7775
continue 2;

src/Symfony/Component/DependencyInjection/Definition.php

+4
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,10 @@ public function getBindings()
876876
/**
877877
* Sets bindings.
878878
*
879+
* Bindings map $named or FQCN arguments to values that should be
880+
* injected in the matching parameters (of the constructor, of methods
881+
* called and of controller actions).
882+
*
879883
* @param array $bindings
880884
*
881885
* @return $this

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ private function getServiceDefaults(\DOMDocument $xml, $file)
166166
}
167167
$defaults = array(
168168
'tags' => $this->getChildren($defaultsNode, 'tag'),
169-
'bind' => array_map(function ($v) {
170-
return new BoundArgument($v);
171-
}, $this->getArgumentsAsPhp($defaultsNode, 'bind', $file)),
169+
'bind' => array_map(function ($v) { return new BoundArgument($v); }, $this->getArgumentsAsPhp($defaultsNode, 'bind', $file)),
172170
);
173171

174172
foreach ($defaults['tags'] as $tag) {
@@ -358,6 +356,8 @@ private function parseDefinition(\DOMElement $service, $file, array $defaults)
358356

359357
$bindings = $this->getArgumentsAsPhp($service, 'bind', $file);
360358
if (isset($defaults['bind'])) {
359+
// deep clone, to avoid multiple process of the same instance in the
360+
// passes
361361
$bindings = array_merge(unserialize(serialize($defaults['bind'])), $bindings);
362362
}
363363
if ($bindings) {

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,7 @@ private function parseDefaults(array &$content, $file)
294294
throw new InvalidArgumentException(sprintf('Parameter "bind" in "_defaults" must be an array in %s. Check your YAML syntax.', $file));
295295
}
296296

297-
$defaults['bind'] = array_map(function ($v) {
298-
return new BoundArgument($v);
299-
}, $this->resolveServices($defaults['bind'], $file));
297+
$defaults['bind'] = array_map(function ($v) { return new BoundArgument($v); }, $this->resolveServices($defaults['bind'], $file));
300298
}
301299

302300
return $defaults;
@@ -537,7 +535,10 @@ private function parseDefinition($id, $service, $file, array $defaults)
537535
}
538536

539537
if (isset($defaults['bind']) || isset($service['bind'])) {
538+
// deep clone, to avoid multiple process of the same instance in the
539+
// passes
540540
$bindings = isset($defaults['bind']) ? unserialize(serialize($defaults['bind'])) : array();
541+
541542
if (isset($service['bind'])) {
542543
if (!is_array($service['bind'])) {
543544
throw new InvalidArgumentException(sprintf('Parameter "bind" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file));

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ public function testArgumentWithNoTypeHintIsOk()
269269
}
270270

271271
/**
272-
* @dataProvider argumentNameProvider
272+
* @dataProvider provideBindings
273273
*/
274-
public function testBindings($argumentName)
274+
public function testBindings($bindingName)
275275
{
276276
$container = new ContainerBuilder();
277277
$resolver = $container->register('argument_resolver.service')->addArgument(array());
278278

279279
$container->register('foo', RegisterTestController::class)
280-
->setBindings(array($argumentName => new Reference('foo')))
280+
->setBindings(array($bindingName => new Reference('foo')))
281281
->addTag('controller.service_arguments');
282282

283283
$pass = new RegisterControllerArgumentLocatorsPass();
@@ -291,7 +291,7 @@ public function testBindings($argumentName)
291291
$this->assertEquals($expected, $locator->getArgument(0));
292292
}
293293

294-
public function argumentNameProvider()
294+
public function provideBindings()
295295
{
296296
return array(array(ControllerDummy::class), array('$bar'));
297297
}

0 commit comments

Comments
 (0)