Test Failed
Pull Request — master (#737)
by Vadim
08:44
created
src/Framework/Domain/FilterInterceptor.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
52 52
     {
53
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
54
-            if (isset($parameters[$parameter])) {
53
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){
54
+            if (isset($parameters[$parameter])){
55 55
                 continue;
56 56
             }
57 57
 
58 58
             /** @var FilterInterface $filter */
59 59
             $filter = $this->container->get($filterClass);
60 60
 
61
-            if (isset($parameters['@context'])) {
61
+            if (isset($parameters['@context'])){
62 62
                 // other interceptors can define the validation contex
63 63
                 $filter->setContext($parameters['@context']);
64 64
             }
65 65
 
66
-            if (!$filter->isValid()) {
66
+            if (!$filter->isValid()){
67 67
                 return $this->renderInvalid($filter);
68 68
             }
69 69
 
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
      */
82 82
     protected function renderInvalid(FilterInterface $filter)
83 83
     {
84
-        if ($filter instanceof ShouldRenderErrors) {
84
+        if ($filter instanceof ShouldRenderErrors){
85 85
             return $filter->render();
86 86
         }
87 87
 
88
-        switch ($this->strategy) {
88
+        switch ($this->strategy){
89 89
             case self::STRATEGY_JSON_RESPONSE:
90 90
                 return [
91 91
                     'status' => 400,
@@ -104,25 +104,25 @@  discard block
 block discarded – undo
104 104
     private function getDeclaredFilters(string $controller, string $action): array
105 105
     {
106 106
         $key = sprintf('%s:%s', $controller, $action);
107
-        if (array_key_exists($key, $this->cache)) {
107
+        if (array_key_exists($key, $this->cache)){
108 108
             return $this->cache[$key];
109 109
         }
110 110
 
111 111
         $this->cache[$key] = [];
112
-        try {
112
+        try{
113 113
             $method = new \ReflectionMethod($controller, $action);
114
-        } catch (\ReflectionException $e) {
114
+        }catch (\ReflectionException $e){
115 115
             return [];
116 116
         }
117 117
 
118
-        foreach ($method->getParameters() as $parameter) {
118
+        foreach ($method->getParameters() as $parameter){
119 119
             $class = $this->getParameterClass($parameter);
120 120
 
121
-            if ($class === null) {
121
+            if ($class === null){
122 122
                 continue;
123 123
             }
124 124
 
125
-            if ($class->implementsInterface(FilterInterface::class)) {
125
+            if ($class->implementsInterface(FilterInterface::class)){
126 126
                 $this->cache[$key][$parameter->getName()] = $class->getName();
127 127
             }
128 128
         }
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $type = $parameter->getType();
142 142
 
143
-        if (!$type instanceof \ReflectionNamedType) {
143
+        if (!$type instanceof \ReflectionNamedType){
144 144
             return null;
145 145
         }
146 146
 
147
-        if ($type->isBuiltin()) {
147
+        if ($type->isBuiltin()){
148 148
             return null;
149 149
         }
150 150
 
Please login to merge, or discard this patch.
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -50,20 +50,24 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
52 52
     {
53
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
54
-            if (isset($parameters[$parameter])) {
53
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass)
54
+        {
55
+            if (isset($parameters[$parameter]))
56
+            {
55 57
                 continue;
56 58
             }
57 59
 
58 60
             /** @var FilterInterface $filter */
59 61
             $filter = $this->container->get($filterClass);
60 62
 
61
-            if (isset($parameters['@context'])) {
63
+            if (isset($parameters['@context']))
64
+            {
62 65
                 // other interceptors can define the validation contex
63 66
                 $filter->setContext($parameters['@context']);
64 67
             }
65 68
 
66
-            if (!$filter->isValid()) {
69
+            if (!$filter->isValid())
70
+            {
67 71
                 return $this->renderInvalid($filter);
68 72
             }
69 73
 
@@ -81,11 +85,13 @@  discard block
 block discarded – undo
81 85
      */
82 86
     protected function renderInvalid(FilterInterface $filter)
83 87
     {
84
-        if ($filter instanceof ShouldRenderErrors) {
88
+        if ($filter instanceof ShouldRenderErrors)
89
+        {
85 90
             return $filter->render();
86 91
         }
87 92
 
88
-        switch ($this->strategy) {
93
+        switch ($this->strategy)
94
+        {
89 95
             case self::STRATEGY_JSON_RESPONSE:
90 96
                 return [
91 97
                     'status' => 400,
@@ -104,25 +110,32 @@  discard block
 block discarded – undo
104 110
     private function getDeclaredFilters(string $controller, string $action): array
105 111
     {
106 112
         $key = sprintf('%s:%s', $controller, $action);
107
-        if (array_key_exists($key, $this->cache)) {
113
+        if (array_key_exists($key, $this->cache))
114
+        {
108 115
             return $this->cache[$key];
109 116
         }
110 117
 
111 118
         $this->cache[$key] = [];
112
-        try {
119
+        try
120
+        {
113 121
             $method = new \ReflectionMethod($controller, $action);
114
-        } catch (\ReflectionException $e) {
122
+        }
123
+        catch (\ReflectionException $e)
124
+        {
115 125
             return [];
116 126
         }
117 127
 
118
-        foreach ($method->getParameters() as $parameter) {
128
+        foreach ($method->getParameters() as $parameter)
129
+        {
119 130
             $class = $this->getParameterClass($parameter);
120 131
 
121
-            if ($class === null) {
132
+            if ($class === null)
133
+            {
122 134
                 continue;
123 135
             }
124 136
 
125
-            if ($class->implementsInterface(FilterInterface::class)) {
137
+            if ($class->implementsInterface(FilterInterface::class))
138
+            {
126 139
                 $this->cache[$key][$parameter->getName()] = $class->getName();
127 140
             }
128 141
         }
@@ -140,11 +153,13 @@  discard block
 block discarded – undo
140 153
     {
141 154
         $type = $parameter->getType();
142 155
 
143
-        if (!$type instanceof \ReflectionNamedType) {
156
+        if (!$type instanceof \ReflectionNamedType)
157
+        {
144 158
             return null;
145 159
         }
146 160
 
147
-        if ($type->isBuiltin()) {
161
+        if ($type->isBuiltin())
162
+        {
148 163
             return null;
149 164
         }
150 165
 
Please login to merge, or discard this patch.