Passed
Push — master ( e7ebae...ecc5ac )
by Valentin
04:51 queued 11s
created
src/Framework/Domain/GuardInterceptor.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
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
             throw new ControllerException($permission[2], $permission[1]);
46 46
         }
47 47
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Framework/Domain/GuardPermissionsProvider.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
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
             $this->cache[$key] = $this->generatePermission($controller, $action);
51 51
         }
52 52
 
@@ -55,20 +55,20 @@  discard block
 block discarded – undo
55 55
 
56 56
     private function generatePermission(string $controller, string $action): ?array
57 57
     {
58
-        try {
58
+        try{
59 59
             $method = new \ReflectionMethod($controller, $action);
60
-        } catch (\ReflectionException $e) {
60
+        }catch (\ReflectionException $e){
61 61
             return null;
62 62
         }
63 63
 
64 64
         $guarded = $this->reader->getMethodAnnotation($method, Guarded::class);
65
-        if (!$guarded instanceof Guarded) {
65
+        if (!$guarded instanceof Guarded){
66 66
             return null;
67 67
         }
68 68
 
69 69
         $namespace = $this->reader->getClassAnnotation($method->getDeclaringClass(), GuardNamespace::class);
70 70
 
71
-        if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)) {
71
+        if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)){
72 72
             return [
73 73
                 $this->makePermission($guarded, $method, $namespace),
74 74
                 $this->mapFailureException($guarded),
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
     private function makePermission(Guarded $guarded, \ReflectionMethod $method, ?GuardNamespace $ns): string
92 92
     {
93 93
         $permission = [];
94
-        if ($this->namespace) {
94
+        if ($this->namespace){
95 95
             $permission[] = $this->namespace;
96 96
         }
97 97
 
98
-        if ($ns !== null && $ns->namespace) {
98
+        if ($ns !== null && $ns->namespace){
99 99
             $permission[] = $ns->namespace;
100 100
         }
101 101
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,7 +46,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
tests/app/src/Controller/Demo3Controller.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,8 +23,10 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.