10000 ResolveBindingsPass remove loading of class iterable · symfony/symfony@f9f78c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit f9f78c7

Browse files
sveneldnicolas-grekas
authored andcommitted
ResolveBindingsPass remove loading of class iterable
1 parent c7a5902 commit f9f78c7

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected function processValue($value, $isRoot = false)
125125
$this->unusedBindings[$bindingId] = [$key, $this->currentId, $bindingType, $file];
126126
}
127127

128-
if (preg_match('/^(?:(?:array|bool|float|int|string|([^ $]++)) )\$/', $key, $m)) {
128+
if (preg_match('/^(?:(?:array|bool|float|int|string|iterable|([^ $]++)) )\$/', $key, $m)) {
129129
$bindingNames[substr($key, \strlen($m[0]))] = $binding;
130130
}
131131

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveBindingsPassTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum;
2828
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
2929
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedEnumArgumentDummy;
30+
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedIterableArgumentDummy;
3031
use Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists;
3132
use Symfony\Component\DependencyInjection\TypedReference;
3233

@@ -209,4 +210,17 @@ public function testEmptyBindingTypehint()
209210
$pass = new ResolveBindingsPass();
210211
$pass->process($container);
211212
}
213+
214+
public function testIterableBindingTypehint()
215+
{
216+
$container = new ContainerBuilder();
217+
$definition = $container->register('bar', NamedIterableArgumentDummy::class);
218+
$definition->setBindings([
219+
'iterable $items' => new TaggedIteratorArgument('foo'),
220+
]);
221+
$pass = new ResolveBindingsPass();
222+
$pass->process($container);
223+
224+
$this->assertInstanceOf(TaggedIteratorArgument::class, $container->getDefinition('bar')->getArgument(0));
225+
}
212226
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
13+
14+
class NamedIterableArgumentDummy
15+
{
16+
public function __construct(iterable $items)
17+
{
18+
}
19+
}

0 commit comments

Comments
 (0)
0