File tree 2 files changed +26
-3
lines changed
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -715,7 +715,7 @@ public function build($concrete)
715
715
// hand back the results of the functions, which allows functions to be
716
716
// used as resolvers for more fine-tuned resolution of these objects.
717
717
if ($ concrete instanceof Closure) {
718
- return $ concrete ($ this , end ( $ this ->with ));
718
+ return $ concrete ($ this , $ this ->getLastParameterOverride ( ));
719
719
}
720
720
721
721
$ reflector = new ReflectionClass ($ concrete );
@@ -793,7 +793,7 @@ protected function resolveDependencies(array $dependencies)
793
793
*/
794
794
protected function hasParameterOverride ($ dependency )
795
795
{
796
- return array_key_exists ($ dependency ->name , end ( $ this ->with ));
796
+ return array_key_exists ($ dependency ->name , $ this ->getLastParameterOverride ( ));
797
797
}
798
798
799
799
/**
@@ -804,7 +804,17 @@ protected function hasParameterOverride($dependency)
804
804
*/
805
805
protected function getParameterOverride ($ dependency )
806
806
{
807
- return end ($ this ->with )[$ dependency ->name ];
807
+ return $ this ->getLastParameterOverride ()[$ dependency ->name ];
808
+ }
809
+
810
+ /**
811
+ * Get the last parameter override.
812
+ *
813
+ * @return array
814
+ */
815
+ protected function getLastParameterOverride ()
816
+ {
817
+ return count ($ this ->with ) ? end ($ this ->with ) : [];
808
818
}
809
819
810
820
/**
Original file line number Diff line number Diff line change @@ -838,6 +838,19 @@ public function testSingletonBindingsNotRespectedWithMakeParameters()
838
838
$ this ->assertEquals (['name ' => 'taylor ' ], $ container ->makeWith ('foo ' , ['name ' => 'taylor ' ]));
839
839
$ this ->assertEquals (['name ' => 'abigail ' ], $ container ->makeWith ('foo ' , ['name ' => 'abigail ' ]));
840
840
}
841
+
842
+ public function testCanBuildWithoutParameterStackWithNoConstructors ()
843
+ {
844
+ $ container = new Container ;
845
+ $ this ->assertInstanceOf (ContainerConcreteStub::class, $ container ->build (ContainerConcreteStub::class));
846
+ }
847
+
848
+ public function testCanBuildWithoutParameterStackWithConstructors ()
849
+ {
850
+ $ container = new Container ;
851
+ $ container ->bind ('Illuminate\Tests\Container\IContainerContractStub ' , 'Illuminate\Tests\Container\ContainerImplementationStub ' );
852
+ $ this ->assertInstanceOf (ContainerDependentStub::class, $ container ->build (ContainerDependentStub::class));
853
+ }
841
854
}
842
855
843
856
class ContainerConcreteStub
You can’t perform that action at this time.
0 commit comments