@@ 83-105 (lines=23) @@ | ||
80 | $newInstanceParams = []; |
|
81 | ||
82 | // Loop over the constructor arguments |
|
83 | foreach ($params as $param) { |
|
84 | // Here we should perform a bunch of checks, such as: |
|
85 | // isArray(), isCallable(), isDefaultValueAvailable() |
|
86 | // isOptional() etc. |
|
87 | ||
88 | // For now, we just check to see if the argument is |
|
89 | // a class, so we can instantiate it, |
|
90 | // otherwise we just pass null. |
|
91 | if (is_null($param->getClass())) { |
|
92 | $newInstanceParams[] = null; |
|
93 | continue; |
|
94 | } |
|
95 | ||
96 | // This is where 'the magic happens'. We resolve each |
|
97 | // of the dependencies, by recursively calling the |
|
98 | // resolve() method. |
|
99 | // At one point, we will reach the bottom of the |
|
100 | // nested dependencies we need in order to instantiate |
|
101 | // the class. |
|
102 | $newInstanceParams[] = $this->resolve( |
|
103 | "\\" . $param->getClass()->getName() |
|
104 | ); |
|
105 | } |
|
106 | ||
107 | // Return the reflected class, instantiated with all its |
|
108 | // dependencies (this happens once for all the |
@@ 95-103 (lines=9) @@ | ||
92 | ||
93 | $injection = []; |
|
94 | ||
95 | foreach ($params as $param) { |
|
96 | // Here we should perform a bunch of checks, such as: isArray(), isCallable(), isDefaultValueAvailable() |
|
97 | // isOptional() etc. |
|
98 | if (is_null($param->getClass())) { |
|
99 | $injection[] = null; |
|
100 | continue; |
|
101 | } |
|
102 | $injection[] = $this->resolve("\\" . $param->getClass()->getName()); |
|
103 | } |
|
104 | ||
105 | return $injection; |
|
106 | } |