1 public function build($concrete)
2 {
3 // If the concrete type is actually a Closure, we will just execute it and
4 // hand back the results of the functions, which allows functions to be
5 // used as resolvers for more fine-tuned resolution of these objects.
6 //若传入的是一个闭包则直接通过闭包实例化类,这种闭包一般由provider类在laravel应用初始化阶段通过bind方法进行绑定。
7 if ($concrete instanceof Closure) {
8 return $concrete($this, $this->getLastParameterOverride());
9 }
10 //制造一个类反射
11 $reflector = new ReflectionClass($concrete);
12
13 // If the type is not instantiable, the developer is attempting to resolve
14 // an abstract type such as an Interface of Abstract Class and there is
15 // no binding registered for the abstractions so we need to bail out.
16 if (! $reflector->isInstantiable()) {
17 return $this->notInstantiable($concrete);
18 }
19 //将当前所实例化的类存入栈
20 $this->buildStack[] = $concrete;
21 //获得该类构造方法
22 $con