8000 bug #34732 [DependencyInjection][Xml] Fix the attribute 'tag' is not … · symfony/symfony@28e1d1e · GitHub
[go: up one dir, main page]

Skip to content

Commit 28e1d1e

Browse files
committed
bug #34732 [DependencyInjection][Xml] Fix the attribute 'tag' is not allowed in 'bind' tag (tienvx)
This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection][Xml] Fix the attribute 'tag' is not allowed in 'bind' tag | Q | A | ------------- | --- | Branch? | 4.4 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | N/A <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | symfony/symfony-docs/pull/12741 <!-- required for new features --> Add test case for https://symfony.com/blog/new-in-symfony-4-4-dependency-injection-improvements-part-1#allow-binding-tagged-services and fix a bug with attribute 'tag' is not allowed Commits ------- e38f7d4 [DependencyInjection][Xml] Fix the attribute 'tag' is not allowed in 'bind' tag
2 parents 9b658ed + e38f7d4 commit 28e1d1e

File tree

6 files changed

+8
-1
lines changed

6 files changed

+8
-1
lines changed

src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
<xsd:attribute name="key" type="xsd:string" use="required" />
223223
<xsd:attribute name="on-invalid" type="invalid_sequence" />
224224
<xsd:attribute name="method" type="xsd:string" />
225+
<xsd:attribute name="tag" type="xsd:string" />
225226
</xsd:complexType>
226227

227228
<xsd:complexType name="argument" mixed="true">

src/Symfony/Component/DependencyInjection/Tests/Fixtures/Bar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Bar implements BarInterface
1515
{
1616
public $quz;
1717

18-
public function __construct($quz = null, \NonExistent $nonExistent = null, BarInterface $decorated = null, array $foo = [])
18+
public function __construct($quz = null, \NonExistent $nonExistent = null, BarInterface $decorated = null, array $foo = [], iterable $baz = [])
1919
{
2020
$this->quz = $quz;
2121
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_bindings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<bind key="$foo" type="collection">
1313
<bind>null</bind>
1414
</bind>
15+
<bind key="iterable $baz" type="tagged_iterator" tag="bar"/>
1516
</service>
1617

1718
<service id="Symfony\Component\DependencyInjection\Tests\Fixtures\Bar">

src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_bindings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
bind:
1313
Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface: '@Symfony\Component\DependencyInjection\Tests\Fixtures\Bar'
1414
$foo: [ ~ ]
15+
iterable $baz: !tagged_iterator bar
1516

1617
Symfony\Component\DependencyInjection\Tests\Fixtures\Bar:
1718
factory: [ ~, 'create' ]

src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,12 +879,14 @@ public function testBindings()
879879
'$foo' => [null],
880880
'$quz' => 'quz',
881881
'$factory' => 'factory',
882+
'iterable $baz' => new TaggedIteratorArgument('bar'),
882883
], array_map(function (BoundArgument $v) { return $v->getValues()[0]; }, $definition->getBindings()));
883884
$this->assertEquals([
884885
'quz',
885886
null,
886887
new Reference(Bar::class),
887888
[null],
889+
new TaggedIteratorArgument('bar'),
888890
], $definition->getArguments());
889891

890892
$definition = $container->getDefinition(Bar::class);

src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,12 +801,14 @@ public function testBindings()
801801
'$foo' => [null],
802802
'$quz&# 7AC7 39; => 'quz',
803803
'$factory' => 'factory',
804+
'iterable $baz' => new TaggedIteratorArgument('bar'),
804805
], array_map(function (BoundArgument $v) { return $v->getValues()[0]; }, $definition->getBindings()));
805806
$this->assertEquals([
806807
'quz',
807808
null,
808809
new Reference(Bar::class),
809810
[null],
811+
new TaggedIteratorArgument('bar'),
810812
], $definition->getArguments());
811813

812814
$definition = $container->getDefinition(Bar::class);

0 commit comments

Comments
 (0)
0