@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Resta\Contracts\ApplicationContracts; |
10 | 10 | use Resta\Exception\FileNotFoundException; |
11 | 11 | |
12 | -class Container implements ContainerContracts,\ArrayAccess |
|
12 | +class Container implements ContainerContracts, \ArrayAccess |
|
13 | 13 | { |
14 | 14 | /** |
15 | 15 | * @var bool |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | * @param array $bind |
52 | 52 | * @return array |
53 | 53 | */ |
54 | - public function applicationProviderBinding($make,$bind=array()) |
|
54 | + public function applicationProviderBinding($make, $bind = array()) |
|
55 | 55 | { |
56 | 56 | //service container is an automatic application provider |
57 | 57 | //that we can bind to the special class di in the dependency condition. |
58 | 58 | //This method is automatically added to the classes resolved by the entire make bind method. |
59 | - return array_merge($bind,['app'=>$make]); |
|
59 | + return array_merge($bind, ['app'=>$make]); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | * @throws DependencyException |
69 | 69 | * @throws NotFoundException |
70 | 70 | */ |
71 | - public function bind($object=null,$callback=null,$alias=null) |
|
71 | + public function bind($object = null, $callback = null, $alias = null) |
|
72 | 72 | { |
73 | - if(!is_null($alias)){ |
|
73 | + if (!is_null($alias)) { |
|
74 | 74 | $object = $alias; |
75 | 75 | } |
76 | 76 | |
77 | 77 | //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object. |
78 | 78 | //Otherwise, when the bind object and callback are sent, the closure class inherits |
79 | 79 | //the applicationProvider object and the resolve method is called |
80 | - return $this->make($object,$callback,'container'); |
|
80 | + return $this->make($object, $callback, 'container'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | * @throws DependencyException |
90 | 90 | * @throws NotFoundException |
91 | 91 | */ |
92 | - private function build($object,$callback,$sync=false) |
|
92 | + private function build($object, $callback, $sync = false) |
|
93 | 93 | { |
94 | 94 | //If the console object returns true, |
95 | 95 | //we do not cancel binding operations |
96 | 96 | //We are getting what applies to console with consoleKernelObject. |
97 | - if($sync===false) return $this->consoleKernelObjectChecker($object,$callback); |
|
97 | + if ($sync===false) return $this->consoleKernelObjectChecker($object, $callback); |
|
98 | 98 | |
99 | 99 | //the value corresponding to the bind value for the global object is assigned and |
100 | 100 | //the resolve method is called for the dependency injection. |
101 | - $this->kernelAssigner()->setKernelObject($object,$callback); |
|
101 | + $this->kernelAssigner()->setKernelObject($object, $callback); |
|
102 | 102 | |
103 | 103 | //return kernel object |
104 | 104 | return $this->kernel(); |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | * @throws DependencyException |
114 | 114 | * @throws NotFoundException |
115 | 115 | */ |
116 | - private function consoleKernelObject($object,$callback,$container=false) |
|
116 | + private function consoleKernelObject($object, $callback, $container = false) |
|
117 | 117 | { |
118 | 118 | //we use the console bindings class to specify the classes to be preloaded in the console application. |
119 | 119 | //Thus, classes that can not be bound with http are called without closure in global loaders directory. |
120 | - $this->resolve(ConsoleBindings::class)->console($object,$callback,$container); |
|
120 | + $this->resolve(ConsoleBindings::class)->console($object, $callback, $container); |
|
121 | 121 | |
122 | 122 | //The console application must always return the kernel method. |
123 | 123 | return $this->kernel(); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @throws DependencyException |
133 | 133 | * @throws NotFoundException |
134 | 134 | */ |
135 | - private function consoleKernelObjectChecker($object,$callback,$container=false) |
|
135 | + private function consoleKernelObjectChecker($object, $callback, $container = false) |
|
136 | 136 | { |
137 | 137 | //we check whether the callback value is a callable function. |
138 | 138 | $isCallableForCallback = is_callable($callback); |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | //If the console object returns true, |
141 | 141 | //we do not cancel binding operations |
142 | 142 | //We are getting what applies to console with consoleKernelObject. |
143 | - if($this->console() AND $isCallableForCallback) return $this->consoleKernelObject($object,$callback,$container); |
|
143 | + if ($this->console() AND $isCallableForCallback) return $this->consoleKernelObject($object, $callback, $container); |
|
144 | 144 | |
145 | 145 | //If the application is not a console operation, we re-bind to existing methods synchronously. |
146 | - return ($container) ? $this->containerBuild($object,$callback,true) : $this->build($object,$callback,true); |
|
146 | + return ($container) ? $this->containerBuild($object, $callback, true) : $this->build($object, $callback, true); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | * @throws DependencyException |
154 | 154 | * @throws NotFoundException |
155 | 155 | */ |
156 | - private function consoleShared($object,$callback) |
|
156 | + private function consoleShared($object, $callback) |
|
157 | 157 | { |
158 | 158 | //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound. |
159 | 159 | //The work to be done here is to bind the classes to be included in the console share privately. |
160 | - $this->kernelAssigner()->consoleShared($object,$callback); |
|
160 | + $this->kernelAssigner()->consoleShared($object, $callback); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | * @throws DependencyException |
170 | 170 | * @throws NotFoundException |
171 | 171 | */ |
172 | - public function containerBuild($object,$callback,$sync=false) |
|
172 | + public function containerBuild($object, $callback, $sync = false) |
|
173 | 173 | { |
174 | 174 | //If the console object returns true, |
175 | 175 | //we do not cancel binding operations |
176 | 176 | //We are getting what applies to console with consoleKernelObject. |
177 | - if($sync===false) return $this->consoleKernelObjectChecker($object,$callback,true); |
|
177 | + if ($sync===false) return $this->consoleKernelObjectChecker($object, $callback, true); |
|
178 | 178 | |
179 | 179 | //Since the objects that come to the build method are objects from the container method, |
180 | 180 | //we need to automatically create a kernel object named serviceContainer in this method. |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | //the value corresponding to the bind value for the global object is assigned and |
184 | 184 | //the resolve method is called for the dependency method. |
185 | - $this->kernelAssigner()->setKernelObject($object,$callback,'serviceContainer'); |
|
185 | + $this->kernelAssigner()->setKernelObject($object, $callback, 'serviceContainer'); |
|
186 | 186 | |
187 | 187 | //return kernel object |
188 | 188 | return $this->kernel(); |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | * @param $class |
193 | 193 | * @param $bind |
194 | 194 | */ |
195 | - private function contextualBindCleaner($class,$bind) |
|
195 | + private function contextualBindCleaner($class, $bind) |
|
196 | 196 | { |
197 | 197 | //the context bind objects are checked again and the bind sequence submitted by |
198 | 198 | //the user is checked and forced to re-instantiate the object. |
199 | - if(isset(self::$instance[$class]) && self::$bindParams[$class]!==$bind){ |
|
199 | + if (isset(self::$instance[$class]) && self::$bindParams[$class]!==$bind) { |
|
200 | 200 | unset(self::$instance[$class]); |
201 | 201 | unset(self::$bindParams[$class]); |
202 | 202 | } |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | |
220 | 220 | // the has method can have a dotted string value so |
221 | 221 | // we need to be able to control the string or array within the container. |
222 | - foreach (explode(".",$abstract) as $item){ |
|
223 | - if(isset($container[$item])){ |
|
222 | + foreach (explode(".", $abstract) as $item) { |
|
223 | + if (isset($container[$item])) { |
|
224 | 224 | $container = $container[$item]; |
225 | 225 | } |
226 | - else{ |
|
226 | + else { |
|
227 | 227 | $containerClosureResolver[] = $item; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | - if(count($containerClosureResolver)>0){ |
|
232 | - $container = ContainerClosureResolver::get(implode('.',$containerClosureResolver)); |
|
231 | + if (count($containerClosureResolver)>0) { |
|
232 | + $container = ContainerClosureResolver::get(implode('.', $containerClosureResolver)); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | return $container; |
@@ -254,22 +254,22 @@ discard block |
||
254 | 254 | |
255 | 255 | // the has method can have a dotted string value so |
256 | 256 | // we need to be able to control the string or array within the container. |
257 | - foreach (explode(".",$abstract) as $item){ |
|
257 | + foreach (explode(".", $abstract) as $item) { |
|
258 | 258 | |
259 | 259 | // this blog will work |
260 | 260 | // if the data in the container loop points to an array. |
261 | - if(!is_array($container)){ |
|
261 | + if (!is_array($container)) { |
|
262 | 262 | |
263 | 263 | // we are querying the value of |
264 | 264 | // the items corresponding to the dotted value in the container. |
265 | 265 | // the control result is transferred to the bools array. |
266 | 266 | $container = $container[$item]; |
267 | 267 | |
268 | - if(is_null($container)){ |
|
268 | + if (is_null($container)) { |
|
269 | 269 | $containerClosureResolver[] = $item; |
270 | - $container = ContainerClosureResolver::get(implode('.',$containerClosureResolver)); |
|
270 | + $container = ContainerClosureResolver::get(implode('.', $containerClosureResolver)); |
|
271 | 271 | |
272 | - if(is_callable($container)){ |
|
272 | + if (is_callable($container)) { |
|
273 | 273 | $bools = []; |
274 | 274 | $container = true; |
275 | 275 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | $bools[] = is_null($container) ? false : true; |
279 | 279 | } |
280 | - else{ |
|
280 | + else { |
|
281 | 281 | // if the container array corresponds to a string, |
282 | 282 | // the bools array is filled with the isset control directly. |
283 | 283 | $bools[] = isset($container[$item]) ? true : false; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | |
287 | 287 | // the method returns false if the bools sequence is false, |
288 | 288 | // otherwise it will return true. |
289 | - return in_array(false,$bools) ? false : true; |
|
289 | + return in_array(false, $bools) ? false : true; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @throws DependencyException |
337 | 337 | * @throws NotFoundException |
338 | 338 | */ |
339 | - public function make($object=null,$callback=null,$container=false) |
|
339 | + public function make($object = null, $callback = null, $container = false) |
|
340 | 340 | { |
341 | 341 | //we check whether the boolean value of the singleton variable used |
342 | 342 | //for booting does not reset every time the object variable to be assigned to the kernel variable is true |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | |
345 | 345 | //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound. |
346 | 346 | //The work to be done here is to bind the classes to be included in the console share privately. |
347 | - if($container){ |
|
348 | - $this->consoleShared($object,$callback); |
|
347 | + if ($container) { |
|
348 | + $this->consoleShared($object, $callback); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | //If the third parameter passed to the bind method carries a container value, |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object. |
356 | 356 | //Otherwise, when the bind object and callback are sent, the closure class inherits |
357 | 357 | //the applicationProvider object and the resolve method is called |
358 | - return ($object===null) ? $this->kernel() : $this->{$makeBuild}($object,$callback); |
|
358 | + return ($object===null) ? $this->kernel() : $this->{$makeBuild}($object, $callback); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function offsetGet($offset) { |
377 | 377 | |
378 | - return $this->resolve($this->instances['containerInstanceResolve'],[ |
|
378 | + return $this->resolve($this->instances['containerInstanceResolve'], [ |
|
379 | 379 | 'instances' => $this->instances |
380 | 380 | ])->{$offset}(); |
381 | 381 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param null $concrete |
400 | 400 | * @return bool|mixed |
401 | 401 | */ |
402 | - public function register($key,$object,$concrete=null) |
|
402 | + public function register($key, $object, $concrete = null) |
|
403 | 403 | { |
404 | 404 | // we assign the values required |
405 | 405 | // for register to the global value variable. |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | |
410 | 410 | // If there is an instance of the application class, |
411 | 411 | // the register method is saved both in this example and in the global. |
412 | - if(defined('appInstance')){ |
|
412 | + if (defined('appInstance')) { |
|
413 | 413 | |
414 | 414 | // where we will assign both the global instance |
415 | 415 | // and the registered application object. |
@@ -428,19 +428,19 @@ discard block |
||
428 | 428 | * @param bool $withConcrete |
429 | 429 | * @return bool |
430 | 430 | */ |
431 | - private function registerProcess($instance,$withConcrete=false) |
|
431 | + private function registerProcess($instance, $withConcrete = false) |
|
432 | 432 | { |
433 | 433 | // values recorded without concrete. |
434 | 434 | // or values deleted |
435 | - if(false===$withConcrete){ |
|
435 | + if (false===$withConcrete) { |
|
436 | 436 | |
437 | 437 | //values registered without concrete |
438 | - $instance->{$this->values['key']}=$this->values['object']; |
|
438 | + $instance->{$this->values['key']} = $this->values['object']; |
|
439 | 439 | return false; |
440 | 440 | } |
441 | 441 | |
442 | 442 | //values registered with concrete |
443 | - $instance->{$this->values['key']}[$this->values['object']]=$this->values['concrete']; |
|
443 | + $instance->{$this->values['key']}[$this->values['object']] = $this->values['concrete']; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
@@ -451,22 +451,22 @@ discard block |
||
451 | 451 | * @throws DependencyException |
452 | 452 | * @throws NotFoundException |
453 | 453 | */ |
454 | - public function resolve($class,$bind=array()) |
|
454 | + public function resolve($class, $bind = array()) |
|
455 | 455 | { |
456 | 456 | //the context bind objects are checked again and the bind sequence submitted by |
457 | 457 | //the user is checked and forced to re-instantiate the object. |
458 | - $this->contextualBindCleaner($class,$bind); |
|
458 | + $this->contextualBindCleaner($class, $bind); |
|
459 | 459 | |
460 | 460 | //We do an instance check to get the static instance values of |
461 | 461 | //the classes to be resolved with the make bind method. |
462 | - if(!isset(self::$instance[$class])){ |
|
462 | + if (!isset(self::$instance[$class])) { |
|
463 | 463 | |
464 | 464 | //bind params object |
465 | 465 | self::$bindParams[$class] = $bind; |
466 | 466 | |
467 | 467 | //By singleton checking, we solve the dependency injection of the given class. |
468 | 468 | //Thus, each class can be called together with its dependency. |
469 | - self::$instance[$class] = DIContainerManager::make($class,$this->applicationProviderBinding($this,self::$bindParams[$class])); |
|
469 | + self::$instance[$class] = DIContainerManager::make($class, $this->applicationProviderBinding($this, self::$bindParams[$class])); |
|
470 | 470 | $this->singleton()->resolved[$class] = self::$instance[$class]; |
471 | 471 | |
472 | 472 | //return resolve class |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | * @param $class |
485 | 485 | * @return mixed |
486 | 486 | */ |
487 | - public function resolved($class){ |
|
487 | + public function resolved($class) { |
|
488 | 488 | |
489 | - if(isset($this['resolved'][$class])){ |
|
489 | + if (isset($this['resolved'][$class])) { |
|
490 | 490 | return $this['resolved'][$class]; |
491 | 491 | } |
492 | 492 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @throws DependencyException |
502 | 502 | * @throws NotFoundException |
503 | 503 | */ |
504 | - public function share($object=null,$callback=null) |
|
504 | + public function share($object = null, $callback = null) |
|
505 | 505 | { |
506 | 506 | //we check whether the boolean value of the singleton variable used |
507 | 507 | //for booting does not reset every time the object variable to be assigned to the kernel variable is true |
@@ -509,12 +509,12 @@ discard block |
||
509 | 509 | |
510 | 510 | //The console share is evaluated as a true variable to be assigned as the 3rd parameter in the classes to be bound. |
511 | 511 | //The work to be done here is to bind the classes to be included in the console share privately. |
512 | - $this->consoleShared($object,$callback); |
|
512 | + $this->consoleShared($object, $callback); |
|
513 | 513 | |
514 | 514 | //If the bind method does not have parameters object and callback, the value is directly assigned to the kernel object. |
515 | 515 | //Otherwise, when the bind object and callback are sent, the closure class inherits |
516 | 516 | //the applicationProvider object and the resolve method is called |
517 | - return ($object===null) ? $this->kernel() : $this->build($object,$callback); |
|
517 | + return ($object===null) ? $this->kernel() : $this->build($object, $callback); |
|
518 | 518 | |
519 | 519 | } |
520 | 520 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | */ |
535 | 535 | public function singleton() |
536 | 536 | { |
537 | - if($this->singleton===false){ |
|
537 | + if ($this->singleton===false) { |
|
538 | 538 | |
539 | 539 | //after first initializing, the singleton variable is set to true, |
540 | 540 | //and subsequent incoming classes can inherit the loaded object. |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | // for application instance |
556 | 556 | // if the values to be saved are to be saved without the concrete, |
557 | 557 | // if it is an array. |
558 | - if($this->values['concrete']===null) { |
|
558 | + if ($this->values['concrete']===null) { |
|
559 | 559 | |
560 | 560 | // Without concrete, |
561 | 561 | // the saved value will be saved |
562 | 562 | // if the it does not exist in application instance. |
563 | - if(!isset($instance->{$this->values['key']})) { |
|
563 | + if (!isset($instance->{$this->values['key']})) { |
|
564 | 564 | $this->registerProcess($instance); |
565 | 565 | } |
566 | 566 | return false; |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | |
569 | 569 | // We send concrete values to be recorded with concrete as true. |
570 | 570 | // these values will be recorded as a array. |
571 | - $this->registerProcess($instance,true); |
|
571 | + $this->registerProcess($instance, true); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -576,11 +576,11 @@ discard block |
||
576 | 576 | * @param null|string $object |
577 | 577 | * @return mixed |
578 | 578 | */ |
579 | - public function terminate($key,$object=null) |
|
579 | + public function terminate($key, $object = null) |
|
580 | 580 | { |
581 | 581 | // object null is |
582 | 582 | // sent to just terminate a key. |
583 | - if($object===null){ |
|
583 | + if ($object===null) { |
|
584 | 584 | unset(core()->{$key}); |
585 | 585 | unset($this->singleton()->{$key}); |
586 | 586 | return false; |
@@ -94,7 +94,9 @@ discard block |
||
94 | 94 | //If the console object returns true, |
95 | 95 | //we do not cancel binding operations |
96 | 96 | //We are getting what applies to console with consoleKernelObject. |
97 | - if($sync===false) return $this->consoleKernelObjectChecker($object,$callback); |
|
97 | + if($sync===false) { |
|
98 | + return $this->consoleKernelObjectChecker($object,$callback); |
|
99 | + } |
|
98 | 100 | |
99 | 101 | //the value corresponding to the bind value for the global object is assigned and |
100 | 102 | //the resolve method is called for the dependency injection. |
@@ -140,7 +142,9 @@ discard block |
||
140 | 142 | //If the console object returns true, |
141 | 143 | //we do not cancel binding operations |
142 | 144 | //We are getting what applies to console with consoleKernelObject. |
143 | - if($this->console() AND $isCallableForCallback) return $this->consoleKernelObject($object,$callback,$container); |
|
145 | + if($this->console() AND $isCallableForCallback) { |
|
146 | + return $this->consoleKernelObject($object,$callback,$container); |
|
147 | + } |
|
144 | 148 | |
145 | 149 | //If the application is not a console operation, we re-bind to existing methods synchronously. |
146 | 150 | return ($container) ? $this->containerBuild($object,$callback,true) : $this->build($object,$callback,true); |
@@ -174,7 +178,9 @@ discard block |
||
174 | 178 | //If the console object returns true, |
175 | 179 | //we do not cancel binding operations |
176 | 180 | //We are getting what applies to console with consoleKernelObject. |
177 | - if($sync===false) return $this->consoleKernelObjectChecker($object,$callback,true); |
|
181 | + if($sync===false) { |
|
182 | + return $this->consoleKernelObjectChecker($object,$callback,true); |
|
183 | + } |
|
178 | 184 | |
179 | 185 | //Since the objects that come to the build method are objects from the container method, |
180 | 186 | //we need to automatically create a kernel object named serviceContainer in this method. |
@@ -222,8 +228,7 @@ discard block |
||
222 | 228 | foreach (explode(".",$abstract) as $item){ |
223 | 229 | if(isset($container[$item])){ |
224 | 230 | $container = $container[$item]; |
225 | - } |
|
226 | - else{ |
|
231 | + } else{ |
|
227 | 232 | $containerClosureResolver[] = $item; |
228 | 233 | } |
229 | 234 | } |
@@ -276,8 +281,7 @@ discard block |
||
276 | 281 | } |
277 | 282 | |
278 | 283 | $bools[] = is_null($container) ? false : true; |
279 | - } |
|
280 | - else{ |
|
284 | + } else{ |
|
281 | 285 | // if the container array corresponds to a string, |
282 | 286 | // the bools array is filled with the isset control directly. |
283 | 287 | $bools[] = isset($container[$item]) ? true : false; |
@@ -20,34 +20,34 @@ |
||
20 | 20 | { |
21 | 21 | $serviceJson = app()->containerCacheFile(); |
22 | 22 | |
23 | - if(file_exists($serviceJson)){ |
|
23 | + if (file_exists($serviceJson)) { |
|
24 | 24 | JsonHandler::$file = $serviceJson; |
25 | 25 | $serviceJson = JsonHandler::get(); |
26 | 26 | |
27 | - $dottedKey = explode('.',$key); |
|
27 | + $dottedKey = explode('.', $key); |
|
28 | 28 | |
29 | - if(count($dottedKey)==2){ |
|
29 | + if (count($dottedKey)==2) { |
|
30 | 30 | |
31 | - if(isset($serviceJson['container'][$dottedKey[0]][$dottedKey[1]])){ |
|
31 | + if (isset($serviceJson['container'][$dottedKey[0]][$dottedKey[1]])) { |
|
32 | 32 | $arrayData = $serviceJson['container'][$dottedKey[0]][$dottedKey[1]]; |
33 | 33 | |
34 | - if($serviceJson['container-format'][$dottedKey[0]][$dottedKey[1]]=='string'){ |
|
34 | + if ($serviceJson['container-format'][$dottedKey[0]][$dottedKey[1]]=='string') { |
|
35 | 35 | return $arrayData; |
36 | 36 | } |
37 | 37 | |
38 | - if($serviceJson['container-format'][$dottedKey[0]][$dottedKey[1]]=='closure'){ |
|
38 | + if ($serviceJson['container-format'][$dottedKey[0]][$dottedKey[1]]=='closure') { |
|
39 | 39 | return SuperClosure::get($arrayData); |
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
43 | - else{ |
|
43 | + else { |
|
44 | 44 | |
45 | - if(isset($serviceJson['container'][$key])){ |
|
46 | - if($serviceJson['container-format'][$key]=='string' || is_array($serviceJson['container-format'][$key])){ |
|
45 | + if (isset($serviceJson['container'][$key])) { |
|
46 | + if ($serviceJson['container-format'][$key]=='string' || is_array($serviceJson['container-format'][$key])) { |
|
47 | 47 | return $serviceJson['container'][$key]; |
48 | 48 | } |
49 | 49 | |
50 | - if($serviceJson['container-format'][$key]=='closure'){ |
|
50 | + if ($serviceJson['container-format'][$key]=='closure') { |
|
51 | 51 | return SuperClosure::get($serviceJson['container'][$key]); |
52 | 52 | } |
53 | 53 | } |
@@ -39,8 +39,7 @@ |
||
39 | 39 | return SuperClosure::get($arrayData); |
40 | 40 | } |
41 | 41 | } |
42 | - } |
|
43 | - else{ |
|
42 | + } else{ |
|
44 | 43 | |
45 | 44 | if(isset($serviceJson['container'][$key])){ |
46 | 45 | if($serviceJson['container-format'][$key]=='string' || is_array($serviceJson['container-format'][$key])){ |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * @param bool $console |
49 | 49 | * @param null $containerCacheFile |
50 | 50 | */ |
51 | - public function __construct($console=false,$containerCacheFile=null) |
|
51 | + public function __construct($console = false, $containerCacheFile = null) |
|
52 | 52 | { |
53 | 53 | //get console status for cli |
54 | 54 | $this->console = (is_bool($console)) ? $console : true; |
55 | 55 | |
56 | - if(!is_null($containerCacheFile)){ |
|
56 | + if (!is_null($containerCacheFile)) { |
|
57 | 57 | $this->containerCacheFile = $containerCacheFile; |
58 | 58 | } |
59 | 59 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | // the booted objects are saved to the kernel. |
74 | 74 | // this method checks whether these objects are registered. |
75 | - return (isset($this['bindings'],$this['bindings'][$object])); |
|
75 | + return (isset($this['bindings'], $this['bindings'][$object])); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | // taking care of the differences between operating system |
89 | 89 | // and escaping arguments to prevent security issues. |
90 | 90 | // It replaces PHP functions like exec, passthru, shell_exec and system |
91 | - return $this->resolve(Command::class,['command'=>$command,'args'=>$arguments])->handle(); |
|
91 | + return $this->resolve(Command::class, ['command'=>$command, 'args'=>$arguments])->handle(); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function config($config) |
115 | 115 | { |
116 | - if($this->checkBindings(__FUNCTION__)){ |
|
116 | + if ($this->checkBindings(__FUNCTION__)) { |
|
117 | 117 | |
118 | 118 | /** @var Macro $macro */ |
119 | 119 | $macro = $this['macro']; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | // this includes the configuration macro class. |
122 | 122 | // therefore, you can expand your configuration settings from |
123 | 123 | // the application kernel identifier to the desired class. |
124 | - return $macro->withStatic(Config::macro(),function() use($config){ |
|
124 | + return $macro->withStatic(Config::macro(), function() use($config){ |
|
125 | 125 | return Config::make($config); |
126 | 126 | })->get(); |
127 | 127 | |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | { |
156 | 156 | // this is the method that allows container records |
157 | 157 | // to be written to a json file. |
158 | - if(!is_null($containerCacheFile = containerCacheFile())){ |
|
158 | + if (!is_null($containerCacheFile = containerCacheFile())) { |
|
159 | 159 | return $containerCacheFile; |
160 | 160 | } |
161 | 161 | |
162 | 162 | // if the container json file is null |
163 | 163 | // then a registered container value is assigned. |
164 | - if(!is_null($this->containerCacheFile)){ |
|
164 | + if (!is_null($this->containerCacheFile)) { |
|
165 | 165 | return $this->containerCacheFile; |
166 | 166 | } |
167 | 167 | |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | * @param array $environment |
187 | 187 | * @return mixed|string |
188 | 188 | */ |
189 | - public function environment($environment=array()) |
|
189 | + public function environment($environment = array()) |
|
190 | 190 | { |
191 | - if($this->checkBindings(__FUNCTION__)){ |
|
191 | + if ($this->checkBindings(__FUNCTION__)) { |
|
192 | 192 | |
193 | 193 | $arguments = (isset(func_get_args()[0])) |
194 | 194 | ? func_get_args()[0] : func_get_args(); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $environmentContainer = $this['environment']; |
198 | 198 | |
199 | 199 | return $environmentContainer->environment( |
200 | - $arguments,$this['environmentVariables'] |
|
200 | + $arguments, $this['environmentVariables'] |
|
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | public function isLocale() : bool |
230 | 230 | { |
231 | 231 | //check environment for local |
232 | - return $this->environment() === 'local'; |
|
232 | + return $this->environment()==='local'; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | |
244 | 244 | // with the help of reflection instance, |
245 | 245 | // we get the kernel properties extended with the application object. |
246 | - foreach ($this['reflection']($this)->getProperties() as $property){ |
|
246 | + foreach ($this['reflection']($this)->getProperties() as $property) { |
|
247 | 247 | $properties[] = $property->getName(); |
248 | 248 | } |
249 | 249 | |
250 | 250 | // we get the names of |
251 | 251 | // the kernel properties ended with groups through the Collection class. |
252 | - [$groups] = Collection::make($properties)->partition(function($properties){ |
|
253 | - return Str::endsWith($properties,'Groups'); |
|
252 | + [$groups] = Collection::make($properties)->partition(function($properties) { |
|
253 | + return Str::endsWith($properties, 'Groups'); |
|
254 | 254 | }); |
255 | 255 | |
256 | 256 | //as a result, kernel groups are being returned. |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | $list = []; |
268 | 268 | |
269 | 269 | //get kernel group names with manifest method |
270 | - foreach ($this->kernelGroupKeys() as $groupKey){ |
|
271 | - $list = array_merge($list,$this->manifest($groupKey)); |
|
270 | + foreach ($this->kernelGroupKeys() as $groupKey) { |
|
271 | + $list = array_merge($list, $this->manifest($groupKey)); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | return $list; |
@@ -284,14 +284,14 @@ discard block |
||
284 | 284 | { |
285 | 285 | // it adds the values in path data specified |
286 | 286 | // by callback to the configuration values. |
287 | - if($this['config'] instanceof ConfigProviderContracts){ |
|
287 | + if ($this['config'] instanceof ConfigProviderContracts) { |
|
288 | 288 | |
289 | 289 | //set your path for config loader |
290 | - tap($this['config'],function(ConfigProviderContracts $config) use($callback) { |
|
290 | + tap($this['config'], function(ConfigProviderContracts $config) use($callback) { |
|
291 | 291 | $config->setConfig(call_user_func($callback)); |
292 | 292 | }); |
293 | 293 | } |
294 | - else{ |
|
294 | + else { |
|
295 | 295 | //set config instance exception for application |
296 | 296 | exception()->unexpectedValue('config instance is not loaded for application container'); |
297 | 297 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @param array $loaders |
304 | 304 | * @return mixed|void |
305 | 305 | */ |
306 | - public function loadIfNotExistBoot($loaders=array()) |
|
306 | + public function loadIfNotExistBoot($loaders = array()) |
|
307 | 307 | { |
308 | 308 | //get kernel group list from application |
309 | 309 | $kernelGroupList = $this->kernelGroupList(); |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | /** @var ClosureDispatcherContracts $closureBootLoader */ |
312 | 312 | $closureBootLoader = $this['closureBootLoader']; |
313 | 313 | |
314 | - foreach ($loaders as $loader){ |
|
314 | + foreach ($loaders as $loader) { |
|
315 | 315 | |
316 | 316 | // if a service needs another boot service, |
317 | 317 | // the service is directly installed here and the service needs are resolved. |
318 | - if(isset($kernelGroupList[$loader]) && $this->checkBindings($loader)===false){ |
|
318 | + if (isset($kernelGroupList[$loader]) && $this->checkBindings($loader)===false) { |
|
319 | 319 | |
320 | 320 | //with the boot loader kernel,we get the boot loader method. |
321 | - $closureBootLoader->call(function() use($loader,$kernelGroupList) { |
|
321 | + $closureBootLoader->call(function() use($loader, $kernelGroupList) { |
|
322 | 322 | |
323 | 323 | /** @var BootLoader $bootLoader */ |
324 | 324 | $bootLoader = $this; |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | $bootstrapper = $this['bootstrapper']; |
342 | 342 | |
343 | 343 | //kernel manifest bootstrapper |
344 | - return $bootstrapper->bootFire(null,$maker); |
|
344 | + return $bootstrapper->bootFire(null, $maker); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | public function runningInConsole() : bool |
353 | 353 | { |
354 | 354 | //Determine if the application is running in the console. |
355 | - return php_sapi_name() === 'cli' || php_sapi_name() === 'phpdbg'; |
|
355 | + return php_sapi_name()==='cli' || php_sapi_name()==='phpdbg'; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | : []; |
369 | 369 | |
370 | 370 | //core kernel providers and project providers have been merged |
371 | - return array_merge($this->manifest('providers'),$providers); |
|
371 | + return array_merge($this->manifest('providers'), $providers); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -378,12 +378,12 @@ discard block |
||
378 | 378 | * @param string $path |
379 | 379 | * @return mixed|void |
380 | 380 | */ |
381 | - public function setPaths($name,$path) |
|
381 | + public function setPaths($name, $path) |
|
382 | 382 | { |
383 | 383 | // save the globally identified paths to |
384 | 384 | // the global container object of the resta. |
385 | - if(file_exists($path)){ |
|
386 | - $this->register('paths',$name,$path); |
|
385 | + if (file_exists($path)) { |
|
386 | + $this->register('paths', $name, $path); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @throws FileNotFoundException |
28 | 28 | */ |
29 | - private function applyProvider($key,$provider,$method='register') |
|
29 | + private function applyProvider($key, $provider, $method = 'register') |
|
30 | 30 | { |
31 | 31 | // If the provider classes are a real object |
32 | 32 | // we will run them. |
33 | - if(Utils::isNamespaceExists($provider)){ |
|
33 | + if (Utils::isNamespaceExists($provider)) { |
|
34 | 34 | |
35 | 35 | // after determining whether the register or boot methods |
36 | 36 | // we are running the provider. |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | $providerInstance = $this->app->resolve($provider); |
39 | 39 | |
40 | 40 | //we need to do method check for provider. |
41 | - if(method_exists($providerInstance,$method)){ |
|
41 | + if (method_exists($providerInstance, $method)) { |
|
42 | 42 | $providerInstance->{$method}(); |
43 | 43 | |
44 | - if($method=="register"){ |
|
44 | + if ($method=="register") { |
|
45 | 45 | /** @scrutinizer ignore-call */ |
46 | - $this->app->register('loadedProviders',$key,$provider); |
|
47 | - $this->deferrableProvider($providerInstance,$provider); |
|
46 | + $this->app->register('loadedProviders', $key, $provider); |
|
47 | + $this->deferrableProvider($providerInstance, $provider); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @throws FileNotFoundException |
60 | 60 | */ |
61 | - private function deferrableProvider($providerInstance,$provider) |
|
61 | + private function deferrableProvider($providerInstance, $provider) |
|
62 | 62 | { |
63 | 63 | $serviceJson = $this->app->containerCacheFile(); |
64 | 64 | |
65 | - if(!isset($serviceJson['providers'][$provider])) { |
|
65 | + if (!isset($serviceJson['providers'][$provider])) { |
|
66 | 66 | |
67 | 67 | if ($providerInstance instanceof DeferrableProvider && file_exists($serviceJson)) { |
68 | 68 | $deferrableProvides = $providerInstance->provides(); |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | } else { |
92 | 92 | foreach ($container as $containerKey => $containerItem) { |
93 | 93 | if ($containerItem instanceof \Closure) { |
94 | - JsonHandler::set('container.' . $deferrableProvide . '.' . $containerKey . '', SuperClosure::set($containerItem)); |
|
95 | - JsonHandler::set('container-format.' . $deferrableProvide . '.' . $containerKey, 'closure'); |
|
94 | + JsonHandler::set('container.'.$deferrableProvide.'.'.$containerKey.'', SuperClosure::set($containerItem)); |
|
95 | + JsonHandler::set('container-format.'.$deferrableProvide.'.'.$containerKey, 'closure'); |
|
96 | 96 | } else { |
97 | - JsonHandler::set('container.' . $deferrableProvide . '.' . $containerKey . '', $containerItem); |
|
98 | - JsonHandler::set('container-format.' . $deferrableProvide . '.' . $containerKey, 'string'); |
|
97 | + JsonHandler::set('container.'.$deferrableProvide.'.'.$containerKey.'', $containerItem); |
|
98 | + JsonHandler::set('container-format.'.$deferrableProvide.'.'.$containerKey, 'string'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | */ |
116 | 116 | private function assignerLoadedProvidersInitialCoreValue() |
117 | 117 | { |
118 | - if(!isset($this->app['loadedProviders'])){ |
|
118 | + if (!isset($this->app['loadedProviders'])) { |
|
119 | 119 | |
120 | 120 | // for loaded providers, |
121 | 121 | // we register an empty array for the container object. |
122 | 122 | /** @scrutinizer ignore-call */ |
123 | - $this->app->register('loadedProviders',[]); |
|
123 | + $this->app->register('loadedProviders', []); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | /** @scrutinizer ignore-call */ |
136 | 136 | $providers = $this->app->serviceProviders(); |
137 | 137 | |
138 | - if(count($providers)){ |
|
138 | + if (count($providers)) { |
|
139 | 139 | $this->providers = $providers; |
140 | 140 | } |
141 | 141 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function handle() |
151 | 151 | { |
152 | - define ('serviceprovider',true); |
|
152 | + define('serviceprovider', true); |
|
153 | 153 | |
154 | 154 | //check providers and resolve |
155 | 155 | $this->resolveProviders($this->getServiceProviders()); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @throws FileNotFoundException |
164 | 164 | */ |
165 | - public function resolveProviders($providers=array()) |
|
165 | + public function resolveProviders($providers = array()) |
|
166 | 166 | { |
167 | 167 | // for loaded providers, |
168 | 168 | // we register an empty array for the container object. |
@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | |
171 | 171 | $serviceJson = []; |
172 | 172 | |
173 | - if(file_exists($this->app->containerCacheFile())){ |
|
173 | + if (file_exists($this->app->containerCacheFile())) { |
|
174 | 174 | JsonHandler::$file = $this->app->containerCacheFile(); |
175 | 175 | $serviceJson = JsonHandler::get(); |
176 | 176 | } |
177 | 177 | |
178 | 178 | //first we are running register methods of provider classes. |
179 | - foreach($providers as $key=>$provider){ |
|
179 | + foreach ($providers as $key=>$provider) { |
|
180 | 180 | |
181 | 181 | // providers can only be installed once. |
182 | 182 | // apply providers and register for kernel |
183 | - if(!isset($this->app['loadedProviders'][$key])){ |
|
183 | + if (!isset($this->app['loadedProviders'][$key])) { |
|
184 | 184 | |
185 | - if(is_array($provider) && isset($provider['class']) && isset($provider['status']) && $provider['status']){ |
|
186 | - if(!isset($serviceJson['providers-deferrable-classes'][$provider['class']])){ |
|
187 | - $this->applyProvider($key,$provider['class']); |
|
185 | + if (is_array($provider) && isset($provider['class']) && isset($provider['status']) && $provider['status']) { |
|
186 | + if (!isset($serviceJson['providers-deferrable-classes'][$provider['class']])) { |
|
187 | + $this->applyProvider($key, $provider['class']); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | } |
193 | 193 | |
194 | 194 | //then we are running boot methods of provider classes. |
195 | - foreach($providers as $key=>$provider){ |
|
195 | + foreach ($providers as $key=>$provider) { |
|
196 | 196 | |
197 | 197 | //if the providers register is already booted. |
198 | - if(isset($this->app['loadedProviders'][$key])){ |
|
199 | - $this->applyProvider($key,$provider,'boot'); |
|
198 | + if (isset($this->app['loadedProviders'][$key])) { |
|
199 | + $this->applyProvider($key, $provider, 'boot'); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
@@ -40,23 +40,23 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @return mixed |
42 | 42 | */ |
43 | - public function console(); |
|
43 | + public function console(); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @return mixed |
47 | 47 | */ |
48 | - public function containerCacheFile(); |
|
48 | + public function containerCacheFile(); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @return mixed |
52 | 52 | */ |
53 | - public function corePath(); |
|
53 | + public function corePath(); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param array $environment |
57 | 57 | * @return mixed |
58 | 58 | */ |
59 | - public function environment($environment=array()); |
|
59 | + public function environment($environment=array()); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @param $abstract |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * @return mixed |
69 | 69 | */ |
70 | - public function handle(); |
|
70 | + public function handle(); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @param $abstract |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * @param $instance |
81 | 81 | * @return mixed |
82 | 82 | */ |
83 | - public function instance ($abstract,$instance); |
|
83 | + public function instance ($abstract,$instance); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @return mixed |
87 | 87 | */ |
88 | - public function isLocale(); |
|
88 | + public function isLocale(); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @method kernel |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * @return array |
98 | 98 | */ |
99 | - public function kernelGroupKeys(); |
|
99 | + public function kernelGroupKeys(); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * @return array |
103 | 103 | */ |
104 | - public function kernelGroupList(); |
|
104 | + public function kernelGroupList(); |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @param callable $callback |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param string $path |
177 | 177 | * @return mixed |
178 | 178 | */ |
179 | - public function setPaths($name,$path); |
|
179 | + public function setPaths($name,$path); |
|
180 | 180 | |
181 | 181 | /** |
182 | 182 | * @param null $object |
@@ -201,5 +201,5 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * @return mixed |
203 | 203 | */ |
204 | - public function version(); |
|
204 | + public function version(); |
|
205 | 205 | } |
206 | 206 | \ No newline at end of file |