File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Symfony \Component \DependencyInjection \Tests \Fixtures ;
4
+
5
+ class BarFactory
6
+ {
7
+ /**
8
+ * @var iterable
9
+ */
10
+ private $ bars ;
11
+
12
+ public function __construct (iterable $ bars )
13
+ {
14
+ $ this ->bars = \iterator_to_array ($ bars );
15
+ }
16
+
17
+ public function getDefaultBar (): BarInterface
18
+ {
19
+ return reset ($ this ->bars );
20
+ }
21
+ }
Original file line number Diff line number Diff line change
1
+ services :
2
+ _instanceof :
3
+ Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface :
4
+ tags :
5
+ - { name: bar }
6
+
7
+ Symfony\Component\DependencyInjection\Tests\Fixtures\Bar :
8
+ public : true
9
+
10
+ Symfony\Component\DependencyInjection\Tests\Fixtures\BarFactory :
11
+ arguments : [!tagged 'bar']
12
+
13
+ Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface :
14
+ factory : ['@Symfony\Component\DependencyInjection\Tests\Fixtures\BarFactory', 'getDefaultBar']
Original file line number Diff line number Diff line change @@ -770,4 +770,15 @@ public function testFqcnLazyProxy()
770
770
$ definition = $ container ->getDefinition ('foo ' );
771
771
$ this ->assertSame ([['interface ' => 'SomeInterface ' ]], $ definition ->getTag ('proxy ' ));
772
772
}
773
+
774
+ public function testServiceWithSameNameAsInterfaceAndFactoryIsNotTagged ()
775
+ {
776
+ $ container = new ContainerBuilder ();
777
+ $ loader = new YamlFileLoader ($ container , new FileLocator (self ::$ fixturesPath .'/yaml ' ));
778
+ $ loader ->load ('service_instanceof_factory.yml ' );
779
+ $ container ->compile ();
780
+
781
+ $ tagged = $ container ->findTaggedServiceIds ('bar ' );
782
+ $ this ->assertCount (1 , $ tagged );
783
+ }
773
784
}
You can’t perform that action at this time.
0 commit comments