| @@ -41,7 +41,8 @@ | ||
| 41 | 41 |      { | 
| 42 | 42 | $permission = $this->permissions->getPermission($controller, $action); | 
| 43 | 43 | |
| 44 | -        if ($permission !== null && !$this->guard->allows($permission[0], $parameters)) { | |
| 44 | + if ($permission !== null && !$this->guard->allows($permission[0], $parameters)) | |
| 45 | +        { | |
| 45 | 46 | throw new ControllerException($permission[2], $permission[1]); | 
| 46 | 47 | } | 
| 47 | 48 | |
| @@ -46,7 +46,8 @@ discard block | ||
| 46 | 46 | public function getPermission(string $controller, string $action): ?array | 
| 47 | 47 |      { | 
| 48 | 48 |          $key = sprintf('%s:%s', $controller, $action); | 
| 49 | -        if (!array_key_exists($key, $this->cache)) { | |
| 49 | + if (!array_key_exists($key, $this->cache)) | |
| 50 | +        { | |
| 50 | 51 | $this->cache[$key] = $this->generatePermission($controller, $action); | 
| 51 | 52 | } | 
| 52 | 53 | |
| @@ -55,20 +56,25 @@ discard block | ||
| 55 | 56 | |
| 56 | 57 | private function generatePermission(string $controller, string $action): ?array | 
| 57 | 58 |      { | 
| 58 | -        try { | |
| 59 | + try | |
| 60 | +        { | |
| 59 | 61 | $method = new \ReflectionMethod($controller, $action); | 
| 60 | -        } catch (\ReflectionException $e) { | |
| 62 | + } | |
| 63 | + catch (\ReflectionException $e) | |
| 64 | +        { | |
| 61 | 65 | return null; | 
| 62 | 66 | } | 
| 63 | 67 | |
| 64 | 68 | $guarded = $this->reader->getMethodAnnotation($method, Guarded::class); | 
| 65 | -        if (!$guarded instanceof Guarded) { | |
| 69 | + if (!$guarded instanceof Guarded) | |
| 70 | +        { | |
| 66 | 71 | return null; | 
| 67 | 72 | } | 
| 68 | 73 | |
| 69 | 74 | $namespace = $this->reader->getClassAnnotation($method->getDeclaringClass(), GuardNamespace::class); | 
| 70 | 75 | |
| 71 | -        if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)) { | |
| 76 | + if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)) | |
| 77 | +        { | |
| 72 | 78 | return [ | 
| 73 | 79 | $this->makePermission($guarded, $method, $namespace), | 
| 74 | 80 | $this->mapFailureException($guarded), | 
| @@ -91,11 +97,13 @@ discard block | ||
| 91 | 97 | private function makePermission(Guarded $guarded, \ReflectionMethod $method, ?GuardNamespace $ns): string | 
| 92 | 98 |      { | 
| 93 | 99 | $permission = []; | 
| 94 | -        if ($this->namespace) { | |
| 100 | + if ($this->namespace) | |
| 101 | +        { | |
| 95 | 102 | $permission[] = $this->namespace; | 
| 96 | 103 | } | 
| 97 | 104 | |
| 98 | -        if ($ns !== null && $ns->namespace) { | |
| 105 | + if ($ns !== null && $ns->namespace) | |
| 106 | +        { | |
| 99 | 107 | $permission[] = $ns->namespace; | 
| 100 | 108 | } | 
| 101 | 109 | |
| @@ -23,8 +23,10 @@ | ||
| 23 | 23 | * @Guarded(permission="") | 
| 24 | 24 | * @return string | 
| 25 | 25 | */ | 
| 26 | - public function do() | |
| 26 | +    public function do{ | |
| 27 | + () | |
| 27 | 28 |      { | 
| 28 | 29 | return 'ok'; | 
| 29 | 30 | } | 
| 31 | + } | |
| 30 | 32 | } |