@@ -16,18 +16,18 @@ discard block |
||
16 | 16 | */ |
17 | 17 | protected static $instance; |
18 | 18 | |
19 | - /** |
|
20 | - * The container's bound services. |
|
21 | - * |
|
22 | - * @var array |
|
23 | - */ |
|
19 | + /** |
|
20 | + * The container's bound services. |
|
21 | + * |
|
22 | + * @var array |
|
23 | + */ |
|
24 | 24 | protected $services = []; |
25 | 25 | |
26 | - /** |
|
27 | - * The container's bucket items |
|
28 | - * |
|
29 | - * @var array |
|
30 | - */ |
|
26 | + /** |
|
27 | + * The container's bucket items |
|
28 | + * |
|
29 | + * @var array |
|
30 | + */ |
|
31 | 31 | protected $bucket = []; |
32 | 32 | |
33 | 33 | /** |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | - * Register a Provider. |
|
127 | - * |
|
128 | - * @return void |
|
129 | - */ |
|
126 | + * Register a Provider. |
|
127 | + * |
|
128 | + * @return void |
|
129 | + */ |
|
130 | 130 | public function register( $provider ) |
131 | 131 | { |
132 | 132 | $provider->register( $this ); |
@@ -148,17 +148,17 @@ discard block |
||
148 | 148 | return $abstract; |
149 | 149 | } |
150 | 150 | |
151 | - /** |
|
152 | - * @param \ReflectionParameter $parameter |
|
153 | - * @return null|\ReflectionClass|\ReflectionNamedType|\ReflectionType |
|
154 | - */ |
|
155 | - protected function getClass($parameter) |
|
156 | - { |
|
157 | - if (version_compare(phpversion(), '8', '<')) { |
|
158 | - return $parameter->getClass(); // @compat PHP < 8 |
|
159 | - } |
|
160 | - return $parameter->getType(); |
|
161 | - } |
|
151 | + /** |
|
152 | + * @param \ReflectionParameter $parameter |
|
153 | + * @return null|\ReflectionClass|\ReflectionNamedType|\ReflectionType |
|
154 | + */ |
|
155 | + protected function getClass($parameter) |
|
156 | + { |
|
157 | + if (version_compare(phpversion(), '8', '<')) { |
|
158 | + return $parameter->getClass(); // @compat PHP < 8 |
|
159 | + } |
|
160 | + return $parameter->getType(); |
|
161 | + } |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Throw an exception that the concrete is not instantiable. |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public static function getInstance() |
39 | 39 | { |
40 | - if( is_null( static::$instance )) { |
|
40 | + if( is_null( static::$instance ) ) { |
|
41 | 41 | static::$instance = new static; |
42 | 42 | } |
43 | 43 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function make( $abstract ) |
70 | 70 | { |
71 | - $service = isset( $this->services[$abstract] ) |
|
71 | + $service = isset($this->services[$abstract]) |
|
72 | 72 | ? $this->services[$abstract] |
73 | 73 | : $this->addNamespace( $abstract ); |
74 | 74 | |
75 | - if( is_callable( $service )) { |
|
75 | + if( is_callable( $service ) ) { |
|
76 | 76 | return call_user_func_array( $service, [$this] ); |
77 | 77 | } |
78 | - if( is_object( $service )) { |
|
78 | + if( is_object( $service ) ) { |
|
79 | 79 | return $service; |
80 | 80 | } |
81 | 81 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function singleton( $abstract, $concrete ) |
94 | 94 | { |
95 | - $this->bind( $abstract, $this->make( $concrete )); |
|
95 | + $this->bind( $abstract, $this->make( $concrete ) ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function __get( $item ) |
106 | 106 | { |
107 | - return isset( $this->bucket[$item] ) |
|
107 | + return isset($this->bucket[$item]) |
|
108 | 108 | ? $this->bucket[$item] |
109 | 109 | : null; |
110 | 110 | } |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function addNamespace( $abstract ) |
143 | 143 | { |
144 | - if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract )) { |
|
145 | - $abstract = __NAMESPACE__ . "\\$abstract"; |
|
144 | + if( strpos( $abstract, __NAMESPACE__ ) === false && !class_exists( $abstract ) ) { |
|
145 | + $abstract = __NAMESPACE__."\\$abstract"; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | return $abstract; |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | * @param \ReflectionParameter $parameter |
153 | 153 | * @return null|\ReflectionClass|\ReflectionNamedType|\ReflectionType |
154 | 154 | */ |
155 | - protected function getClass($parameter) |
|
155 | + protected function getClass( $parameter ) |
|
156 | 156 | { |
157 | - if (version_compare(phpversion(), '8', '<')) { |
|
157 | + if( version_compare( phpversion(), '8', '<' ) ) { |
|
158 | 158 | return $parameter->getClass(); // @compat PHP < 8 |
159 | 159 | } |
160 | 160 | return $parameter->getType(); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | return $this->notInstantiable( $concrete ); |
196 | 196 | } |
197 | 197 | |
198 | - if( is_null(( $constructor = $reflector->getConstructor() ))) { |
|
198 | + if( is_null( ($constructor = $reflector->getConstructor()) ) ) { |
|
199 | 199 | return new $concrete; |
200 | 200 | } |
201 | 201 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | protected function resolveClass( ReflectionParameter $parameter ) |
214 | 214 | { |
215 | 215 | try { |
216 | - return $this->make( $this->getClass($parameter)->getName() ); |
|
216 | + return $this->make( $this->getClass( $parameter )->getName() ); |
|
217 | 217 | } |
218 | 218 | catch( Exception $e ) { |
219 | 219 | if( $parameter->isOptional() ) { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | foreach( $dependencies as $dependency ) { |
236 | 236 | // If the class is null, the dependency is a string or some other primitive type |
237 | - $results[] = !is_null( $class = $this->getClass($dependency) ) |
|
237 | + $results[] = !is_null( $class = $this->getClass( $dependency ) ) |
|
238 | 238 | ? $this->resolveClass( $dependency ) |
239 | 239 | : null; |
240 | 240 | } |