@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function get($alias, string $context = null) |
128 | 128 | { |
129 | - if ($alias instanceof Autowire) { |
|
129 | + if ($alias instanceof Autowire){ |
|
130 | 130 | return $alias->resolve($this); |
131 | 131 | } |
132 | 132 | |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function make(string $alias, array $parameters = [], string $context = null) |
144 | 144 | { |
145 | - if (!isset($this->bindings[$alias])) { |
|
145 | + if (!isset($this->bindings[$alias])){ |
|
146 | 146 | //No direct instructions how to construct class, make is automatically |
147 | 147 | return $this->autowire($alias, $parameters, $context); |
148 | 148 | } |
149 | 149 | |
150 | 150 | $binding = $this->bindings[$alias]; |
151 | - if (is_object($binding)) { |
|
151 | + if (is_object($binding)){ |
|
152 | 152 | //When binding is instance, assuming singleton |
153 | 153 | return $binding; |
154 | 154 | } |
155 | 155 | |
156 | - if (is_string($binding)) { |
|
156 | + if (is_string($binding)){ |
|
157 | 157 | //Binding is pointing to something else |
158 | 158 | return $this->make($binding, $parameters, $context); |
159 | 159 | } |
160 | 160 | |
161 | 161 | unset($this->bindings[$alias]); |
162 | - try { |
|
163 | - if ($binding[0] === $alias) { |
|
162 | + try{ |
|
163 | + if ($binding[0] === $alias){ |
|
164 | 164 | $instance = $this->autowire($alias, $parameters, $context); |
165 | - } else { |
|
165 | + }else{ |
|
166 | 166 | $instance = $this->evaluateBinding($alias, $binding[0], $parameters, $context); |
167 | 167 | } |
168 | - } finally { |
|
168 | + }finally{ |
|
169 | 169 | $this->bindings[$alias] = $binding; |
170 | 170 | } |
171 | 171 | |
172 | - if ($binding[1]) { |
|
172 | + if ($binding[1]){ |
|
173 | 173 | //Indicates singleton |
174 | 174 | $this->bindings[$alias] = $instance; |
175 | 175 | } |
@@ -190,30 +190,30 @@ discard block |
||
190 | 190 | string $context = null |
191 | 191 | ): array { |
192 | 192 | $arguments = []; |
193 | - foreach ($reflection->getParameters() as $parameter) { |
|
194 | - try { |
|
193 | + foreach ($reflection->getParameters() as $parameter){ |
|
194 | + try{ |
|
195 | 195 | //Information we need to know about argument in order to resolve it's value |
196 | 196 | $name = $parameter->getName(); |
197 | 197 | $class = $parameter->getClass(); |
198 | - } catch (Throwable $e) { |
|
198 | + }catch (Throwable $e){ |
|
199 | 199 | //Possibly invalid class definition or syntax error |
200 | 200 | $location = $reflection->getName(); |
201 | - if ($reflection instanceof ReflectionMethod) { |
|
201 | + if ($reflection instanceof ReflectionMethod){ |
|
202 | 202 | $location = "{$reflection->getDeclaringClass()->getName()}->{$location}"; |
203 | 203 | } |
204 | 204 | //Possibly invalid class definition or syntax error |
205 | 205 | throw new ContainerException( |
206 | - "Unable to resolve `{$parameter->getName()}` in {$location}: " . $e->getMessage(), |
|
206 | + "Unable to resolve `{$parameter->getName()}` in {$location}: ".$e->getMessage(), |
|
207 | 207 | $e->getCode(), |
208 | 208 | $e |
209 | 209 | ); |
210 | 210 | } |
211 | 211 | |
212 | - if (isset($parameters[$name]) && is_object($parameters[$name])) { |
|
213 | - if ($parameters[$name] instanceof Autowire) { |
|
212 | + if (isset($parameters[$name]) && is_object($parameters[$name])){ |
|
213 | + if ($parameters[$name] instanceof Autowire){ |
|
214 | 214 | //Supplied by user as late dependency |
215 | 215 | $arguments[] = $parameters[$name]->resolve($this); |
216 | - } else { |
|
216 | + }else{ |
|
217 | 217 | //Supplied by user as object |
218 | 218 | $arguments[] = $parameters[$name]; |
219 | 219 | } |
@@ -221,16 +221,16 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | // no declared type or scalar type or array |
224 | - if (!isset($class)) { |
|
224 | + if (!isset($class)){ |
|
225 | 225 | //Provided from outside |
226 | - if (array_key_exists($name, $parameters)) { |
|
226 | + if (array_key_exists($name, $parameters)){ |
|
227 | 227 | //Make sure it's properly typed |
228 | 228 | $this->assertType($parameter, $reflection, $parameters[$name]); |
229 | 229 | $arguments[] = $parameters[$name]; |
230 | 230 | continue; |
231 | 231 | } |
232 | 232 | |
233 | - if ($parameter->isDefaultValueAvailable()) { |
|
233 | + if ($parameter->isDefaultValueAvailable()){ |
|
234 | 234 | //Default value |
235 | 235 | $arguments[] = $parameter->getDefaultValue(); |
236 | 236 | continue; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | throw new ArgumentException($parameter, $reflection); |
241 | 241 | } |
242 | 242 | |
243 | - try { |
|
243 | + try{ |
|
244 | 244 | //Requesting for contextual dependency |
245 | 245 | $arguments[] = $this->get($class->getName(), $name); |
246 | 246 | continue; |
247 | - } catch (AutowireException $e) { |
|
248 | - if ($parameter->isOptional()) { |
|
247 | + }catch (AutowireException $e){ |
|
248 | + if ($parameter->isOptional()){ |
|
249 | 249 | //This is optional dependency, skip |
250 | 250 | $arguments[] = null; |
251 | 251 | continue; |
@@ -264,28 +264,28 @@ discard block |
||
264 | 264 | public function runScope(array $bindings, callable $scope) |
265 | 265 | { |
266 | 266 | $cleanup = $previous = []; |
267 | - foreach ($bindings as $alias => $resolver) { |
|
268 | - if (isset($this->bindings[$alias])) { |
|
267 | + foreach ($bindings as $alias => $resolver){ |
|
268 | + if (isset($this->bindings[$alias])){ |
|
269 | 269 | $previous[$alias] = $this->bindings[$alias]; |
270 | - } else { |
|
270 | + }else{ |
|
271 | 271 | $cleanup[] = $alias; |
272 | 272 | } |
273 | 273 | |
274 | 274 | $this->bind($alias, $resolver); |
275 | 275 | } |
276 | 276 | |
277 | - try { |
|
278 | - if (ContainerScope::getContainer() !== $this) { |
|
277 | + try{ |
|
278 | + if (ContainerScope::getContainer() !== $this){ |
|
279 | 279 | return ContainerScope::runScope($this, $scope); |
280 | 280 | } |
281 | 281 | |
282 | 282 | return $scope(); |
283 | - } finally { |
|
284 | - foreach (array_reverse($previous) as $alias => $resolver) { |
|
283 | + }finally{ |
|
284 | + foreach (array_reverse($previous) as $alias => $resolver){ |
|
285 | 285 | $this->bindings[$alias] = $resolver; |
286 | 286 | } |
287 | 287 | |
288 | - foreach ($cleanup as $alias) { |
|
288 | + foreach ($cleanup as $alias){ |
|
289 | 289 | unset($this->bindings[$alias]); |
290 | 290 | } |
291 | 291 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function bind(string $alias, $resolver): void |
303 | 303 | { |
304 | - if (is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire) { |
|
304 | + if (is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire){ |
|
305 | 305 | // array means = execute me, false = not singleton |
306 | 306 | $this->bindings[$alias] = [$resolver, false]; |
307 | 307 | return; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function bindSingleton(string $alias, $resolver): void |
321 | 321 | { |
322 | - if (is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire) { |
|
322 | + if (is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire){ |
|
323 | 323 | // direct binding to an instance |
324 | 324 | $this->bindings[$alias] = $resolver; |
325 | 325 | return; |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | */ |
337 | 337 | public function hasInstance(string $alias): bool |
338 | 338 | { |
339 | - if (!$this->has($alias)) { |
|
339 | + if (!$this->has($alias)){ |
|
340 | 340 | return false; |
341 | 341 | } |
342 | 342 | |
343 | - while (isset($this->bindings[$alias]) && is_string($this->bindings[$alias])) { |
|
343 | + while (isset($this->bindings[$alias]) && is_string($this->bindings[$alias])){ |
|
344 | 344 | //Checking alias tree |
345 | 345 | $alias = $this->bindings[$alias]; |
346 | 346 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | */ |
415 | 415 | protected function autowire(string $class, array $parameters, string $context = null) |
416 | 416 | { |
417 | - if (!class_exists($class)) { |
|
417 | + if (!class_exists($class)){ |
|
418 | 418 | throw new NotFoundException(sprintf("Undefined class or binding '%s'", $class)); |
419 | 419 | } |
420 | 420 | |
@@ -436,9 +436,9 @@ discard block |
||
436 | 436 | private function registerInstance($instance, array $parameters) |
437 | 437 | { |
438 | 438 | //Declarative singletons (only when class received via direct get) |
439 | - if ($parameters === [] && $instance instanceof SingletonInterface) { |
|
439 | + if ($parameters === [] && $instance instanceof SingletonInterface){ |
|
440 | 440 | $alias = get_class($instance); |
441 | - if (!isset($this->bindings[$alias])) { |
|
441 | + if (!isset($this->bindings[$alias])){ |
|
442 | 442 | $this->bindings[$alias] = $instance; |
443 | 443 | } |
444 | 444 | } |
@@ -462,20 +462,20 @@ discard block |
||
462 | 462 | $target, |
463 | 463 | array $parameters, |
464 | 464 | string $context = null |
465 | - ) { |
|
466 | - if (is_string($target)) { |
|
465 | + ){ |
|
466 | + if (is_string($target)){ |
|
467 | 467 | //Reference |
468 | 468 | return $this->make($target, $parameters, $context); |
469 | 469 | } |
470 | 470 | |
471 | - if ($target instanceof Autowire) { |
|
471 | + if ($target instanceof Autowire){ |
|
472 | 472 | return $target->resolve($this, $parameters); |
473 | 473 | } |
474 | 474 | |
475 | - if ($target instanceof Closure) { |
|
476 | - try { |
|
475 | + if ($target instanceof Closure){ |
|
476 | + try{ |
|
477 | 477 | $reflection = new ReflectionFunction($target); |
478 | - } catch (ReflectionException $e) { |
|
478 | + }catch (ReflectionException $e){ |
|
479 | 479 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
480 | 480 | } |
481 | 481 | |
@@ -485,16 +485,16 @@ discard block |
||
485 | 485 | ); |
486 | 486 | } |
487 | 487 | |
488 | - if (is_array($target) && isset($target[1])) { |
|
488 | + if (is_array($target) && isset($target[1])){ |
|
489 | 489 | //In a form of resolver and method |
490 | 490 | [$resolver, $method] = $target; |
491 | 491 | |
492 | 492 | //Resolver instance (i.e. [ClassName::class, 'method']) |
493 | 493 | $resolver = $this->get($resolver); |
494 | 494 | |
495 | - try { |
|
495 | + try{ |
|
496 | 496 | $method = new ReflectionMethod($resolver, $method); |
497 | - } catch (ReflectionException $e) { |
|
497 | + }catch (ReflectionException $e){ |
|
498 | 498 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
499 | 499 | } |
500 | 500 | |
@@ -523,22 +523,22 @@ discard block |
||
523 | 523 | */ |
524 | 524 | private function createInstance(string $class, array $parameters, string $context = null) |
525 | 525 | { |
526 | - try { |
|
526 | + try{ |
|
527 | 527 | $reflection = new ReflectionClass($class); |
528 | - } catch (ReflectionException $e) { |
|
528 | + }catch (ReflectionException $e){ |
|
529 | 529 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
530 | 530 | } |
531 | 531 | |
532 | 532 | //We have to construct class using external injector when we know exact context |
533 | - if ($parameters === [] && $this->checkInjector($reflection)) { |
|
533 | + if ($parameters === [] && $this->checkInjector($reflection)){ |
|
534 | 534 | $injector = $this->injectors[$reflection->getName()]; |
535 | 535 | |
536 | 536 | $instance = null; |
537 | - try { |
|
537 | + try{ |
|
538 | 538 | /** @var InjectorInterface $injectorInstance */ |
539 | 539 | $injectorInstance = $this->get($injector); |
540 | 540 | |
541 | - if (!$injectorInstance instanceof InjectorInterface) { |
|
541 | + if (!$injectorInstance instanceof InjectorInterface){ |
|
542 | 542 | throw new InjectionException( |
543 | 543 | sprintf( |
544 | 544 | "Class '%s' must be an instance of InjectorInterface for '%s'", |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | } |
550 | 550 | |
551 | 551 | $instance = $injectorInstance->createInjection($reflection, $context); |
552 | - if (!$reflection->isInstance($instance)) { |
|
552 | + if (!$reflection->isInstance($instance)){ |
|
553 | 553 | throw new InjectionException( |
554 | 554 | sprintf( |
555 | 555 | "Invalid injection response for '%s'", |
@@ -557,23 +557,23 @@ discard block |
||
557 | 557 | ) |
558 | 558 | ); |
559 | 559 | } |
560 | - } finally { |
|
560 | + }finally{ |
|
561 | 561 | $this->injectors[$reflection->getName()] = $injector; |
562 | 562 | } |
563 | 563 | |
564 | 564 | return $instance; |
565 | 565 | } |
566 | 566 | |
567 | - if (!$reflection->isInstantiable()) { |
|
567 | + if (!$reflection->isInstantiable()){ |
|
568 | 568 | throw new ContainerException(sprintf("Class '%s' can not be constructed", $class)); |
569 | 569 | } |
570 | 570 | |
571 | 571 | $constructor = $reflection->getConstructor(); |
572 | 572 | |
573 | - if ($constructor !== null) { |
|
573 | + if ($constructor !== null){ |
|
574 | 574 | // Using constructor with resolved arguments |
575 | 575 | $instance = $reflection->newInstanceArgs($this->resolveArguments($constructor, $parameters)); |
576 | - } else { |
|
576 | + }else{ |
|
577 | 577 | // No constructor specified |
578 | 578 | $instance = $reflection->newInstance(); |
579 | 579 | } |
@@ -590,27 +590,27 @@ discard block |
||
590 | 590 | private function checkInjector(ReflectionClass $reflection): bool |
591 | 591 | { |
592 | 592 | $class = $reflection->getName(); |
593 | - if (array_key_exists($class, $this->injectors)) { |
|
593 | + if (array_key_exists($class, $this->injectors)){ |
|
594 | 594 | return $this->injectors[$class] !== null; |
595 | 595 | } |
596 | 596 | |
597 | 597 | if ( |
598 | 598 | $reflection->implementsInterface(InjectableInterface::class) |
599 | 599 | && $reflection->hasConstant('INJECTOR') |
600 | - ) { |
|
600 | + ){ |
|
601 | 601 | $this->injectors[$class] = $reflection->getConstant('INJECTOR'); |
602 | 602 | return true; |
603 | 603 | } |
604 | 604 | |
605 | - if (!isset($this->injectorsCache[$class])) { |
|
605 | + if (!isset($this->injectorsCache[$class])){ |
|
606 | 606 | $this->injectorsCache[$class] = null; |
607 | 607 | |
608 | 608 | // check interfaces |
609 | - foreach ($this->injectors as $target => $injector) { |
|
609 | + foreach ($this->injectors as $target => $injector){ |
|
610 | 610 | if ( |
611 | 611 | class_exists($target, true) |
612 | 612 | && $reflection->isSubclassOf($target) |
613 | - ) { |
|
613 | + ){ |
|
614 | 614 | $this->injectors[$class] = $injector; |
615 | 615 | return true; |
616 | 616 | } |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | if ( |
619 | 619 | interface_exists($target, true) |
620 | 620 | && $reflection->implementsInterface($target) |
621 | - ) { |
|
621 | + ){ |
|
622 | 622 | $this->injectors[$class] = $injector; |
623 | 623 | return true; |
624 | 624 | } |
@@ -640,11 +640,11 @@ discard block |
||
640 | 640 | */ |
641 | 641 | private function assertType(ReflectionParameter $parameter, ContextFunction $context, $value): void |
642 | 642 | { |
643 | - if ($value === null) { |
|
643 | + if ($value === null){ |
|
644 | 644 | if ( |
645 | 645 | !$parameter->isOptional() && |
646 | 646 | !($parameter->isDefaultValueAvailable() && $parameter->getDefaultValue() === null) |
647 | - ) { |
|
647 | + ){ |
|
648 | 648 | throw new ArgumentException($parameter, $context); |
649 | 649 | } |
650 | 650 | |
@@ -652,20 +652,20 @@ discard block |
||
652 | 652 | } |
653 | 653 | |
654 | 654 | $type = $parameter->getType(); |
655 | - if ($type === null) { |
|
655 | + if ($type === null){ |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | 659 | $typeName = $type->getName(); |
660 | - if ($typeName === 'array' && !is_array($value)) { |
|
660 | + if ($typeName === 'array' && !is_array($value)){ |
|
661 | 661 | throw new ArgumentException($parameter, $context); |
662 | 662 | } |
663 | 663 | |
664 | - if (($typeName === 'int' || $typeName === 'float') && !is_numeric($value)) { |
|
664 | + if (($typeName === 'int' || $typeName === 'float') && !is_numeric($value)){ |
|
665 | 665 | throw new ArgumentException($parameter, $context); |
666 | 666 | } |
667 | 667 | |
668 | - if ($typeName === 'bool' && !is_bool($value) && !is_numeric($value)) { |
|
668 | + if ($typeName === 'bool' && !is_bool($value) && !is_numeric($value)){ |
|
669 | 669 | throw new ArgumentException($parameter, $context); |
670 | 670 | } |
671 | 671 | } |
@@ -126,7 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function get($alias, string $context = null) |
128 | 128 | { |
129 | - if ($alias instanceof Autowire) { |
|
129 | + if ($alias instanceof Autowire) |
|
130 | + { |
|
130 | 131 | return $alias->resolve($this); |
131 | 132 | } |
132 | 133 | |
@@ -142,34 +143,44 @@ discard block |
||
142 | 143 | */ |
143 | 144 | public function make(string $alias, array $parameters = [], string $context = null) |
144 | 145 | { |
145 | - if (!isset($this->bindings[$alias])) { |
|
146 | + if (!isset($this->bindings[$alias])) |
|
147 | + { |
|
146 | 148 | //No direct instructions how to construct class, make is automatically |
147 | 149 | return $this->autowire($alias, $parameters, $context); |
148 | 150 | } |
149 | 151 | |
150 | 152 | $binding = $this->bindings[$alias]; |
151 | - if (is_object($binding)) { |
|
153 | + if (is_object($binding)) |
|
154 | + { |
|
152 | 155 | //When binding is instance, assuming singleton |
153 | 156 | return $binding; |
154 | 157 | } |
155 | 158 | |
156 | - if (is_string($binding)) { |
|
159 | + if (is_string($binding)) |
|
160 | + { |
|
157 | 161 | //Binding is pointing to something else |
158 | 162 | return $this->make($binding, $parameters, $context); |
159 | 163 | } |
160 | 164 | |
161 | 165 | unset($this->bindings[$alias]); |
162 | - try { |
|
163 | - if ($binding[0] === $alias) { |
|
166 | + try |
|
167 | + { |
|
168 | + if ($binding[0] === $alias) |
|
169 | + { |
|
164 | 170 | $instance = $this->autowire($alias, $parameters, $context); |
165 | - } else { |
|
171 | + } |
|
172 | + else |
|
173 | + { |
|
166 | 174 | $instance = $this->evaluateBinding($alias, $binding[0], $parameters, $context); |
167 | 175 | } |
168 | - } finally { |
|
176 | + } |
|
177 | + finally |
|
178 | + { |
|
169 | 179 | $this->bindings[$alias] = $binding; |
170 | 180 | } |
171 | 181 | |
172 | - if ($binding[1]) { |
|
182 | + if ($binding[1]) |
|
183 | + { |
|
173 | 184 | //Indicates singleton |
174 | 185 | $this->bindings[$alias] = $instance; |
175 | 186 | } |
@@ -190,15 +201,20 @@ discard block |
||
190 | 201 | string $context = null |
191 | 202 | ): array { |
192 | 203 | $arguments = []; |
193 | - foreach ($reflection->getParameters() as $parameter) { |
|
194 | - try { |
|
204 | + foreach ($reflection->getParameters() as $parameter) |
|
205 | + { |
|
206 | + try |
|
207 | + { |
|
195 | 208 | //Information we need to know about argument in order to resolve it's value |
196 | 209 | $name = $parameter->getName(); |
197 | 210 | $class = $parameter->getClass(); |
198 | - } catch (Throwable $e) { |
|
211 | + } |
|
212 | + catch (Throwable $e) |
|
213 | + { |
|
199 | 214 | //Possibly invalid class definition or syntax error |
200 | 215 | $location = $reflection->getName(); |
201 | - if ($reflection instanceof ReflectionMethod) { |
|
216 | + if ($reflection instanceof ReflectionMethod) |
|
217 | + { |
|
202 | 218 | $location = "{$reflection->getDeclaringClass()->getName()}->{$location}"; |
203 | 219 | } |
204 | 220 | //Possibly invalid class definition or syntax error |
@@ -209,11 +225,15 @@ discard block |
||
209 | 225 | ); |
210 | 226 | } |
211 | 227 | |
212 | - if (isset($parameters[$name]) && is_object($parameters[$name])) { |
|
213 | - if ($parameters[$name] instanceof Autowire) { |
|
228 | + if (isset($parameters[$name]) && is_object($parameters[$name])) |
|
229 | + { |
|
230 | + if ($parameters[$name] instanceof Autowire) |
|
231 | + { |
|
214 | 232 | //Supplied by user as late dependency |
215 | 233 | $arguments[] = $parameters[$name]->resolve($this); |
216 | - } else { |
|
234 | + } |
|
235 | + else |
|
236 | + { |
|
217 | 237 | //Supplied by user as object |
218 | 238 | $arguments[] = $parameters[$name]; |
219 | 239 | } |
@@ -221,16 +241,19 @@ discard block |
||
221 | 241 | } |
222 | 242 | |
223 | 243 | // no declared type or scalar type or array |
224 | - if (!isset($class)) { |
|
244 | + if (!isset($class)) |
|
245 | + { |
|
225 | 246 | //Provided from outside |
226 | - if (array_key_exists($name, $parameters)) { |
|
247 | + if (array_key_exists($name, $parameters)) |
|
248 | + { |
|
227 | 249 | //Make sure it's properly typed |
228 | 250 | $this->assertType($parameter, $reflection, $parameters[$name]); |
229 | 251 | $arguments[] = $parameters[$name]; |
230 | 252 | continue; |
231 | 253 | } |
232 | 254 | |
233 | - if ($parameter->isDefaultValueAvailable()) { |
|
255 | + if ($parameter->isDefaultValueAvailable()) |
|
256 | + { |
|
234 | 257 | //Default value |
235 | 258 | $arguments[] = $parameter->getDefaultValue(); |
236 | 259 | continue; |
@@ -240,12 +263,16 @@ discard block |
||
240 | 263 | throw new ArgumentException($parameter, $reflection); |
241 | 264 | } |
242 | 265 | |
243 | - try { |
|
266 | + try |
|
267 | + { |
|
244 | 268 | //Requesting for contextual dependency |
245 | 269 | $arguments[] = $this->get($class->getName(), $name); |
246 | 270 | continue; |
247 | - } catch (AutowireException $e) { |
|
248 | - if ($parameter->isOptional()) { |
|
271 | + } |
|
272 | + catch (AutowireException $e) |
|
273 | + { |
|
274 | + if ($parameter->isOptional()) |
|
275 | + { |
|
249 | 276 | //This is optional dependency, skip |
250 | 277 | $arguments[] = null; |
251 | 278 | continue; |
@@ -264,28 +291,38 @@ discard block |
||
264 | 291 | public function runScope(array $bindings, callable $scope) |
265 | 292 | { |
266 | 293 | $cleanup = $previous = []; |
267 | - foreach ($bindings as $alias => $resolver) { |
|
268 | - if (isset($this->bindings[$alias])) { |
|
294 | + foreach ($bindings as $alias => $resolver) |
|
295 | + { |
|
296 | + if (isset($this->bindings[$alias])) |
|
297 | + { |
|
269 | 298 | $previous[$alias] = $this->bindings[$alias]; |
270 | - } else { |
|
299 | + } |
|
300 | + else |
|
301 | + { |
|
271 | 302 | $cleanup[] = $alias; |
272 | 303 | } |
273 | 304 | |
274 | 305 | $this->bind($alias, $resolver); |
275 | 306 | } |
276 | 307 | |
277 | - try { |
|
278 | - if (ContainerScope::getContainer() !== $this) { |
|
308 | + try |
|
309 | + { |
|
310 | + if (ContainerScope::getContainer() !== $this) |
|
311 | + { |
|
279 | 312 | return ContainerScope::runScope($this, $scope); |
280 | 313 | } |
281 | 314 | |
282 | 315 | return $scope(); |
283 | - } finally { |
|
284 | - foreach (array_reverse($previous) as $alias => $resolver) { |
|
316 | + } |
|
317 | + finally |
|
318 | + { |
|
319 | + foreach (array_reverse($previous) as $alias => $resolver) |
|
320 | + { |
|
285 | 321 | $this->bindings[$alias] = $resolver; |
286 | 322 | } |
287 | 323 | |
288 | - foreach ($cleanup as $alias) { |
|
324 | + foreach ($cleanup as $alias) |
|
325 | + { |
|
289 | 326 | unset($this->bindings[$alias]); |
290 | 327 | } |
291 | 328 | } |
@@ -301,7 +338,8 @@ discard block |
||
301 | 338 | */ |
302 | 339 | public function bind(string $alias, $resolver): void |
303 | 340 | { |
304 | - if (is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire) { |
|
341 | + if (is_array($resolver) || $resolver instanceof Closure || $resolver instanceof Autowire) |
|
342 | + { |
|
305 | 343 | // array means = execute me, false = not singleton |
306 | 344 | $this->bindings[$alias] = [$resolver, false]; |
307 | 345 | return; |
@@ -319,7 +357,8 @@ discard block |
||
319 | 357 | */ |
320 | 358 | public function bindSingleton(string $alias, $resolver): void |
321 | 359 | { |
322 | - if (is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire) { |
|
360 | + if (is_object($resolver) && !$resolver instanceof Closure && !$resolver instanceof Autowire) |
|
361 | + { |
|
323 | 362 | // direct binding to an instance |
324 | 363 | $this->bindings[$alias] = $resolver; |
325 | 364 | return; |
@@ -336,11 +375,13 @@ discard block |
||
336 | 375 | */ |
337 | 376 | public function hasInstance(string $alias): bool |
338 | 377 | { |
339 | - if (!$this->has($alias)) { |
|
378 | + if (!$this->has($alias)) |
|
379 | + { |
|
340 | 380 | return false; |
341 | 381 | } |
342 | 382 | |
343 | - while (isset($this->bindings[$alias]) && is_string($this->bindings[$alias])) { |
|
383 | + while (isset($this->bindings[$alias]) && is_string($this->bindings[$alias])) |
|
384 | + { |
|
344 | 385 | //Checking alias tree |
345 | 386 | $alias = $this->bindings[$alias]; |
346 | 387 | } |
@@ -414,7 +455,8 @@ discard block |
||
414 | 455 | */ |
415 | 456 | protected function autowire(string $class, array $parameters, string $context = null) |
416 | 457 | { |
417 | - if (!class_exists($class)) { |
|
458 | + if (!class_exists($class)) |
|
459 | + { |
|
418 | 460 | throw new NotFoundException(sprintf("Undefined class or binding '%s'", $class)); |
419 | 461 | } |
420 | 462 | |
@@ -436,9 +478,11 @@ discard block |
||
436 | 478 | private function registerInstance($instance, array $parameters) |
437 | 479 | { |
438 | 480 | //Declarative singletons (only when class received via direct get) |
439 | - if ($parameters === [] && $instance instanceof SingletonInterface) { |
|
481 | + if ($parameters === [] && $instance instanceof SingletonInterface) |
|
482 | + { |
|
440 | 483 | $alias = get_class($instance); |
441 | - if (!isset($this->bindings[$alias])) { |
|
484 | + if (!isset($this->bindings[$alias])) |
|
485 | + { |
|
442 | 486 | $this->bindings[$alias] = $instance; |
443 | 487 | } |
444 | 488 | } |
@@ -463,19 +507,25 @@ discard block |
||
463 | 507 | array $parameters, |
464 | 508 | string $context = null |
465 | 509 | ) { |
466 | - if (is_string($target)) { |
|
510 | + if (is_string($target)) |
|
511 | + { |
|
467 | 512 | //Reference |
468 | 513 | return $this->make($target, $parameters, $context); |
469 | 514 | } |
470 | 515 | |
471 | - if ($target instanceof Autowire) { |
|
516 | + if ($target instanceof Autowire) |
|
517 | + { |
|
472 | 518 | return $target->resolve($this, $parameters); |
473 | 519 | } |
474 | 520 | |
475 | - if ($target instanceof Closure) { |
|
476 | - try { |
|
521 | + if ($target instanceof Closure) |
|
522 | + { |
|
523 | + try |
|
524 | + { |
|
477 | 525 | $reflection = new ReflectionFunction($target); |
478 | - } catch (ReflectionException $e) { |
|
526 | + } |
|
527 | + catch (ReflectionException $e) |
|
528 | + { |
|
479 | 529 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
480 | 530 | } |
481 | 531 | |
@@ -485,16 +535,20 @@ discard block |
||
485 | 535 | ); |
486 | 536 | } |
487 | 537 | |
488 | - if (is_array($target) && isset($target[1])) { |
|
538 | + if (is_array($target) && isset($target[1])) |
|
539 | + { |
|
489 | 540 | //In a form of resolver and method |
490 | 541 | [$resolver, $method] = $target; |
491 | 542 | |
492 | 543 | //Resolver instance (i.e. [ClassName::class, 'method']) |
493 | 544 | $resolver = $this->get($resolver); |
494 | 545 | |
495 | - try { |
|
546 | + try |
|
547 | + { |
|
496 | 548 | $method = new ReflectionMethod($resolver, $method); |
497 | - } catch (ReflectionException $e) { |
|
549 | + } |
|
550 | + catch (ReflectionException $e) |
|
551 | + { |
|
498 | 552 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
499 | 553 | } |
500 | 554 | |
@@ -523,22 +577,28 @@ discard block |
||
523 | 577 | */ |
524 | 578 | private function createInstance(string $class, array $parameters, string $context = null) |
525 | 579 | { |
526 | - try { |
|
580 | + try |
|
581 | + { |
|
527 | 582 | $reflection = new ReflectionClass($class); |
528 | - } catch (ReflectionException $e) { |
|
583 | + } |
|
584 | + catch (ReflectionException $e) |
|
585 | + { |
|
529 | 586 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
530 | 587 | } |
531 | 588 | |
532 | 589 | //We have to construct class using external injector when we know exact context |
533 | - if ($parameters === [] && $this->checkInjector($reflection)) { |
|
590 | + if ($parameters === [] && $this->checkInjector($reflection)) |
|
591 | + { |
|
534 | 592 | $injector = $this->injectors[$reflection->getName()]; |
535 | 593 | |
536 | 594 | $instance = null; |
537 | - try { |
|
595 | + try |
|
596 | + { |
|
538 | 597 | /** @var InjectorInterface $injectorInstance */ |
539 | 598 | $injectorInstance = $this->get($injector); |
540 | 599 | |
541 | - if (!$injectorInstance instanceof InjectorInterface) { |
|
600 | + if (!$injectorInstance instanceof InjectorInterface) |
|
601 | + { |
|
542 | 602 | throw new InjectionException( |
543 | 603 | sprintf( |
544 | 604 | "Class '%s' must be an instance of InjectorInterface for '%s'", |
@@ -549,7 +609,8 @@ discard block |
||
549 | 609 | } |
550 | 610 | |
551 | 611 | $instance = $injectorInstance->createInjection($reflection, $context); |
552 | - if (!$reflection->isInstance($instance)) { |
|
612 | + if (!$reflection->isInstance($instance)) |
|
613 | + { |
|
553 | 614 | throw new InjectionException( |
554 | 615 | sprintf( |
555 | 616 | "Invalid injection response for '%s'", |
@@ -557,23 +618,29 @@ discard block |
||
557 | 618 | ) |
558 | 619 | ); |
559 | 620 | } |
560 | - } finally { |
|
621 | + } |
|
622 | + finally |
|
623 | + { |
|
561 | 624 | $this->injectors[$reflection->getName()] = $injector; |
562 | 625 | } |
563 | 626 | |
564 | 627 | return $instance; |
565 | 628 | } |
566 | 629 | |
567 | - if (!$reflection->isInstantiable()) { |
|
630 | + if (!$reflection->isInstantiable()) |
|
631 | + { |
|
568 | 632 | throw new ContainerException(sprintf("Class '%s' can not be constructed", $class)); |
569 | 633 | } |
570 | 634 | |
571 | 635 | $constructor = $reflection->getConstructor(); |
572 | 636 | |
573 | - if ($constructor !== null) { |
|
637 | + if ($constructor !== null) |
|
638 | + { |
|
574 | 639 | // Using constructor with resolved arguments |
575 | 640 | $instance = $reflection->newInstanceArgs($this->resolveArguments($constructor, $parameters)); |
576 | - } else { |
|
641 | + } |
|
642 | + else |
|
643 | + { |
|
577 | 644 | // No constructor specified |
578 | 645 | $instance = $reflection->newInstance(); |
579 | 646 | } |
@@ -590,7 +657,8 @@ discard block |
||
590 | 657 | private function checkInjector(ReflectionClass $reflection): bool |
591 | 658 | { |
592 | 659 | $class = $reflection->getName(); |
593 | - if (array_key_exists($class, $this->injectors)) { |
|
660 | + if (array_key_exists($class, $this->injectors)) |
|
661 | + { |
|
594 | 662 | return $this->injectors[$class] !== null; |
595 | 663 | } |
596 | 664 | |
@@ -602,11 +670,13 @@ discard block |
||
602 | 670 | return true; |
603 | 671 | } |
604 | 672 | |
605 | - if (!isset($this->injectorsCache[$class])) { |
|
673 | + if (!isset($this->injectorsCache[$class])) |
|
674 | + { |
|
606 | 675 | $this->injectorsCache[$class] = null; |
607 | 676 | |
608 | 677 | // check interfaces |
609 | - foreach ($this->injectors as $target => $injector) { |
|
678 | + foreach ($this->injectors as $target => $injector) |
|
679 | + { |
|
610 | 680 | if ( |
611 | 681 | class_exists($target, true) |
612 | 682 | && $reflection->isSubclassOf($target) |
@@ -640,7 +710,8 @@ discard block |
||
640 | 710 | */ |
641 | 711 | private function assertType(ReflectionParameter $parameter, ContextFunction $context, $value): void |
642 | 712 | { |
643 | - if ($value === null) { |
|
713 | + if ($value === null) |
|
714 | + { |
|
644 | 715 | if ( |
645 | 716 | !$parameter->isOptional() && |
646 | 717 | !($parameter->isDefaultValueAvailable() && $parameter->getDefaultValue() === null) |
@@ -652,20 +723,24 @@ discard block |
||
652 | 723 | } |
653 | 724 | |
654 | 725 | $type = $parameter->getType(); |
655 | - if ($type === null) { |
|
726 | + if ($type === null) |
|
727 | + { |
|
656 | 728 | return; |
657 | 729 | } |
658 | 730 | |
659 | 731 | $typeName = $type->getName(); |
660 | - if ($typeName === 'array' && !is_array($value)) { |
|
732 | + if ($typeName === 'array' && !is_array($value)) |
|
733 | + { |
|
661 | 734 | throw new ArgumentException($parameter, $context); |
662 | 735 | } |
663 | 736 | |
664 | - if (($typeName === 'int' || $typeName === 'float') && !is_numeric($value)) { |
|
737 | + if (($typeName === 'int' || $typeName === 'float') && !is_numeric($value)) |
|
738 | + { |
|
665 | 739 | throw new ArgumentException($parameter, $context); |
666 | 740 | } |
667 | 741 | |
668 | - if ($typeName === 'bool' && !is_bool($value) && !is_numeric($value)) { |
|
742 | + if ($typeName === 'bool' && !is_bool($value) && !is_numeric($value)) |
|
743 | + { |
|
669 | 744 | throw new ArgumentException($parameter, $context); |
670 | 745 | } |
671 | 746 | } |
@@ -44,8 +44,8 @@ |
||
44 | 44 | $this->context = $context; |
45 | 45 | |
46 | 46 | $name = $context->getName(); |
47 | - if ($context instanceof ReflectionMethod) { |
|
48 | - $name = $context->class . '::' . $name; |
|
47 | + if ($context instanceof ReflectionMethod){ |
|
48 | + $name = $context->class.'::'.$name; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | parent::__construct("Unable to resolve '{$parameter->name}' argument in '{$name}'"); |
@@ -44,7 +44,8 @@ |
||
44 | 44 | $this->context = $context; |
45 | 45 | |
46 | 46 | $name = $context->getName(); |
47 | - if ($context instanceof ReflectionMethod) { |
|
47 | + if ($context instanceof ReflectionMethod) |
|
48 | + { |
|
48 | 49 | $name = $context->class . '::' . $name; |
49 | 50 | } |
50 | 51 |
@@ -71,7 +71,7 @@ |
||
71 | 71 | */ |
72 | 72 | public function offsetGet($offset) |
73 | 73 | { |
74 | - if (!$this->offsetExists($offset)) { |
|
74 | + if (!$this->offsetExists($offset)){ |
|
75 | 75 | throw new ConfigException("Undefined configuration key '{$offset}'"); |
76 | 76 | } |
77 | 77 |
@@ -71,7 +71,8 @@ |
||
71 | 71 | */ |
72 | 72 | public function offsetGet($offset) |
73 | 73 | { |
74 | - if (!$this->offsetExists($offset)) { |
|
74 | + if (!$this->offsetExists($offset)) |
|
75 | + { |
|
75 | 76 | throw new ConfigException("Undefined configuration key '{$offset}'"); |
76 | 77 | } |
77 | 78 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | public function resolveAlias(string $alias): string |
26 | 26 | { |
27 | - while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])) { |
|
27 | + while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])){ |
|
28 | 28 | $alias = $this->config['aliases'][$alias]; |
29 | 29 | } |
30 | 30 |
@@ -24,7 +24,8 @@ |
||
24 | 24 | */ |
25 | 25 | public function resolveAlias(string $alias): string |
26 | 26 | { |
27 | - while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])) { |
|
27 | + while (is_string($alias) && isset($this->config) && isset($this->config['aliases'][$alias])) |
|
28 | + { |
|
28 | 29 | $alias = $this->config['aliases'][$alias]; |
29 | 30 | } |
30 | 31 |
@@ -58,22 +58,22 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function wire($definition): Autowire |
60 | 60 | { |
61 | - if ($definition instanceof self) { |
|
61 | + if ($definition instanceof self){ |
|
62 | 62 | return $definition; |
63 | 63 | } |
64 | 64 | |
65 | - if (is_string($definition)) { |
|
65 | + if (is_string($definition)){ |
|
66 | 66 | return new Autowire($definition); |
67 | 67 | } |
68 | 68 | |
69 | - if (is_array($definition) && isset($definition['class'])) { |
|
69 | + if (is_array($definition) && isset($definition['class'])){ |
|
70 | 70 | return new Autowire( |
71 | 71 | $definition['class'], |
72 | 72 | $definition['options'] ?? $definition['params'] ?? [] |
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
76 | - if (is_object($definition)) { |
|
76 | + if (is_object($definition)){ |
|
77 | 77 | $autowire = new self(get_class($definition), []); |
78 | 78 | $autowire->target = $definition; |
79 | 79 | return $autowire; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function resolve(FactoryInterface $factory, array $parameters = []) |
94 | 94 | { |
95 | - if ($this->target !== null) { |
|
95 | + if ($this->target !== null){ |
|
96 | 96 | // pre-wired |
97 | 97 | return $this->target; |
98 | 98 | } |
@@ -58,22 +58,26 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function wire($definition): Autowire |
60 | 60 | { |
61 | - if ($definition instanceof self) { |
|
61 | + if ($definition instanceof self) |
|
62 | + { |
|
62 | 63 | return $definition; |
63 | 64 | } |
64 | 65 | |
65 | - if (is_string($definition)) { |
|
66 | + if (is_string($definition)) |
|
67 | + { |
|
66 | 68 | return new Autowire($definition); |
67 | 69 | } |
68 | 70 | |
69 | - if (is_array($definition) && isset($definition['class'])) { |
|
71 | + if (is_array($definition) && isset($definition['class'])) |
|
72 | + { |
|
70 | 73 | return new Autowire( |
71 | 74 | $definition['class'], |
72 | 75 | $definition['options'] ?? $definition['params'] ?? [] |
73 | 76 | ); |
74 | 77 | } |
75 | 78 | |
76 | - if (is_object($definition)) { |
|
79 | + if (is_object($definition)) |
|
80 | + { |
|
77 | 81 | $autowire = new self(get_class($definition), []); |
78 | 82 | $autowire->target = $definition; |
79 | 83 | return $autowire; |
@@ -92,7 +96,8 @@ discard block |
||
92 | 96 | */ |
93 | 97 | public function resolve(FactoryInterface $factory, array $parameters = []) |
94 | 98 | { |
95 | - if ($this->target !== null) { |
|
99 | + if ($this->target !== null) |
|
100 | + { |
|
96 | 101 | // pre-wired |
97 | 102 | return $this->target; |
98 | 103 | } |
@@ -54,7 +54,8 @@ |
||
54 | 54 | return $source->withCode( |
55 | 55 | preg_replace_callback( |
56 | 56 | self::REGEXP, |
57 | - function ($matches) use ($domain, $context) { |
|
57 | + function ($matches) use ($domain, $context) |
|
58 | + { |
|
58 | 59 | return $this->translator->trans( |
59 | 60 | $matches[1], |
60 | 61 | [], |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | PermissionsInterface $permissions, |
42 | 42 | ContainerInterface $actorScope, |
43 | 43 | array $roles = [] |
44 | - ) { |
|
44 | + ){ |
|
45 | 45 | $this->roles = $roles; |
46 | 46 | $this->container = $actorScope; |
47 | 47 | $this->permissions = $permissions; |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | public function allows(string $permission, array $context = []): bool |
56 | 56 | { |
57 | 57 | $allows = false; |
58 | - foreach ($this->getRoles() as $role) { |
|
59 | - if (!$this->permissions->hasRole($role)) { |
|
58 | + foreach ($this->getRoles() as $role){ |
|
59 | + if (!$this->permissions->hasRole($role)){ |
|
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getActor(): ActorInterface |
105 | 105 | { |
106 | - if (!is_null($this->actor)) { |
|
106 | + if (!is_null($this->actor)){ |
|
107 | 107 | return $this->actor; |
108 | 108 | } |
109 | 109 | |
110 | - try { |
|
110 | + try{ |
|
111 | 111 | return $this->container->get(ActorInterface::class); |
112 | - } catch (NotFoundExceptionInterface $e) { |
|
112 | + }catch (NotFoundExceptionInterface $e){ |
|
113 | 113 | throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e); |
114 | 114 | } |
115 | 115 | } |
@@ -55,8 +55,10 @@ discard block |
||
55 | 55 | public function allows(string $permission, array $context = []): bool |
56 | 56 | { |
57 | 57 | $allows = false; |
58 | - foreach ($this->getRoles() as $role) { |
|
59 | - if (!$this->permissions->hasRole($role)) { |
|
58 | + foreach ($this->getRoles() as $role) |
|
59 | + { |
|
60 | + if (!$this->permissions->hasRole($role)) |
|
61 | + { |
|
60 | 62 | continue; |
61 | 63 | } |
62 | 64 | |
@@ -103,13 +105,17 @@ discard block |
||
103 | 105 | */ |
104 | 106 | public function getActor(): ActorInterface |
105 | 107 | { |
106 | - if (!is_null($this->actor)) { |
|
108 | + if (!is_null($this->actor)) |
|
109 | + { |
|
107 | 110 | return $this->actor; |
108 | 111 | } |
109 | 112 | |
110 | - try { |
|
113 | + try |
|
114 | + { |
|
111 | 115 | return $this->container->get(ActorInterface::class); |
112 | - } catch (NotFoundExceptionInterface $e) { |
|
116 | + } |
|
117 | + catch (NotFoundExceptionInterface $e) |
|
118 | + { |
|
113 | 119 | throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e); |
114 | 120 | } |
115 | 121 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | */ |
42 | 42 | public function getValue(string $source, string $name = null) |
43 | 43 | { |
44 | - if (!method_exists($this->input, $source)) { |
|
44 | + if (!method_exists($this->input, $source)){ |
|
45 | 45 | throw new InputException("Undefined input source '{$source}'"); |
46 | 46 | } |
47 | 47 |
@@ -41,7 +41,8 @@ |
||
41 | 41 | */ |
42 | 42 | public function getValue(string $source, string $name = null) |
43 | 43 | { |
44 | - if (!method_exists($this->input, $source)) { |
|
44 | + if (!method_exists($this->input, $source)) |
|
45 | + { |
|
45 | 46 | throw new InputException("Undefined input source '{$source}'"); |
46 | 47 | } |
47 | 48 |
@@ -42,13 +42,13 @@ |
||
42 | 42 | { |
43 | 43 | $schema = $this->orm->getSchema(); |
44 | 44 | |
45 | - foreach ($schema->getRoles() as $role) { |
|
45 | + foreach ($schema->getRoles() as $role){ |
|
46 | 46 | $repository = $schema->define($role, Schema::REPOSITORY); |
47 | 47 | |
48 | 48 | if ( |
49 | 49 | $repository !== Select\Repository::class |
50 | 50 | && $repository === $class->getName() |
51 | - ) { |
|
51 | + ){ |
|
52 | 52 | return $this->orm->getRepository($role); |
53 | 53 | } |
54 | 54 | } |
@@ -42,7 +42,8 @@ |
||
42 | 42 | { |
43 | 43 | $schema = $this->orm->getSchema(); |
44 | 44 | |
45 | - foreach ($schema->getRoles() as $role) { |
|
45 | + foreach ($schema->getRoles() as $role) |
|
46 | + { |
|
46 | 47 | $repository = $schema->define($role, Schema::REPOSITORY); |
47 | 48 | |
48 | 49 | if ( |