| Conditions | 5 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | protected function handle(mixed ...$middlewareParams): HttpResponse|Request |
||
| 16 | { |
||
| 17 | if($this->match instanceof MatchRoute) { |
||
| 18 | $reflection = new \ReflectionMethod($this->match->controller, $this->match->method); |
||
| 19 | $attributes = $reflection->getAttributes(); |
||
| 20 | |||
| 21 | foreach ($attributes as $attribute) { |
||
| 22 | if(is_subclass_of($attribute->getName(), AbstractAccessControlAttribute::class)) { |
||
| 23 | return |
||
| 24 | $this->checkPermissions($attribute->getName(), ...($attribute->getArguments()))? |
||
| 25 | $this->request : |
||
| 26 | new RedirectResponse( |
||
| 27 | Application::getAuthConfig()->login_url, |
||
| 28 | redirect_after: $this->request->url |
||
| 29 | ); |
||
| 30 | } |
||
| 31 | |||
| 32 | } |
||
| 33 | return $this->request; |
||
| 34 | } |
||
| 47 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: