File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,10 @@ public function give($implementation)
7575 */
7676 public function giveTagged ($ tag )
7777 {
78+ if (! $ this ->needs ) {
79+ $ this ->needs = $ tag ;
80+ }
81+
7882 $ this ->give (function ($ container ) use ($ tag ) {
7983 $ taggedServices = $ container ->tagged ($ tag );
8084
Original file line number Diff line number Diff line change @@ -359,6 +359,24 @@ public function testContextualBindingGivesTagsForVariadic()
359359 $ this ->assertInstanceOf (ContainerContextImplementationStub::class, $ resolvedInstance ->stubs [0 ]);
360360 $ this ->assertInstanceOf (ContainerContextImplementationStubTwo::class, $ resolvedInstance ->stubs [1 ]);
361361 }
362+
363+ public function testContextualBindingGivesTagsForVariadicNoNeeds ()
364+ {
365+ $ container = new Container ;
366+
367+ $ container ->tag ([
368+ ContainerContextImplementationStub::class,
369+ ContainerContextImplementationStubTwo::class,
370+ ], [IContainerContextContractStub::class]);
371+
372+ $ container ->when (ContainerTestContextInjectVariadic::class)->giveTagged (IContainerContextContractStub::class);
373+
374+ $ resolvedInstance = $ container ->make (ContainerTestContextInjectVariadic::class);
375+
376+ $ this ->assertCount (2 , $ resolvedInstance ->stubs );
377+ $ this ->assertInstanceOf (ContainerContextImplementationStub::class, $ resolvedInstance ->stubs [0 ]);
378+ $ this ->assertInstanceOf (ContainerContextImplementationStubTwo::class, $ resolvedInstance ->stubs [1 ]);
379+ }
362380}
363381
364382interface IContainerContextContractStub
You can’t perform that action at this time.
0 commit comments