Passed
Pull Request — master (#737)
by butschster
07:02
created
src/Framework/Domain/FilterInterceptor.php 2 patches
Braces   +25 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,20 +37,24 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
39 39
     {
40
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
41
-            if (isset($parameters[$parameter])) {
40
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass)
41
+        {
42
+            if (isset($parameters[$parameter]))
43
+            {
42 44
                 continue;
43 45
             }
44 46
 
45 47
             /** @var FilterInterface $filter */
46 48
             $filter = $this->container->get($filterClass);
47 49
 
48
-            if (isset($parameters['@context'])) {
50
+            if (isset($parameters['@context']))
51
+            {
49 52
                 // other interceptors can define the validation contex
50 53
                 $filter->setContext($parameters['@context']);
51 54
             }
52 55
 
53
-            if (!$filter->isValid()) {
56
+            if (!$filter->isValid())
57
+            {
54 58
                 return $this->renderInvalid($filter);
55 59
             }
56 60
 
@@ -79,25 +83,32 @@  discard block
 block discarded – undo
79 83
     private function getDeclaredFilters(string $controller, string $action): array
80 84
     {
81 85
         $key = sprintf('%s:%s', $controller, $action);
82
-        if (array_key_exists($key, $this->cache)) {
86
+        if (array_key_exists($key, $this->cache))
87
+        {
83 88
             return $this->cache[$key];
84 89
         }
85 90
 
86 91
         $this->cache[$key] = [];
87
-        try {
92
+        try
93
+        {
88 94
             $method = new \ReflectionMethod($controller, $action);
89
-        } catch (\ReflectionException $e) {
95
+        }
96
+        catch (\ReflectionException $e)
97
+        {
90 98
             return [];
91 99
         }
92 100
 
93
-        foreach ($method->getParameters() as $parameter) {
101
+        foreach ($method->getParameters() as $parameter)
102
+        {
94 103
             $class = $this->getParameterClass($parameter);
95 104
 
96
-            if ($class === null) {
105
+            if ($class === null)
106
+            {
97 107
                 continue;
98 108
             }
99 109
 
100
-            if ($class->implementsInterface(FilterInterface::class)) {
110
+            if ($class->implementsInterface(FilterInterface::class))
111
+            {
101 112
                 $this->buildCache($parameter, $class, $key);
102 113
             }
103 114
         }
@@ -115,11 +126,13 @@  discard block
 block discarded – undo
115 126
     {
116 127
         $type = $parameter->getType();
117 128
 
118
-        if (!$type instanceof \ReflectionNamedType) {
129
+        if (!$type instanceof \ReflectionNamedType)
130
+        {
119 131
             return null;
120 132
         }
121 133
 
122
-        if ($type->isBuiltin()) {
134
+        if ($type->isBuiltin())
135
+        {
123 136
             return null;
124 137
         }
125 138
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         ContainerInterface $container,
35 35
         int $strategy = self::STRATEGY_JSON_RESPONSE,
36 36
         ?RenderErrorsInterface $renderErrors = null
37
-    ) {
37
+    ){
38 38
         $this->container = $container;
39 39
         $this->strategy = $strategy;
40 40
         $this->renderErrors = $renderErrors ?: new DefaultFilterErrorsRendererInterface($strategy);
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
47 47
     {
48
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
49
-            if (isset($parameters[$parameter])) {
48
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){
49
+            if (isset($parameters[$parameter])){
50 50
                 continue;
51 51
             }
52 52
 
53 53
             /** @var FilterInterface $filter */
54 54
             $filter = $this->container->get($filterClass);
55 55
 
56
-            if (isset($parameters['@context'])) {
56
+            if (isset($parameters['@context'])){
57 57
                 // other interceptors can define the validation contex
58 58
                 $filter->setContext($parameters['@context']);
59 59
             }
60 60
 
61
-            if (!$filter->isValid()) {
61
+            if (!$filter->isValid()){
62 62
                 return $this->renderInvalid($filter);
63 63
             }
64 64
 
@@ -87,25 +87,25 @@  discard block
 block discarded – undo
87 87
     private function getDeclaredFilters(string $controller, string $action): array
88 88
     {
89 89
         $key = sprintf('%s:%s', $controller, $action);
90
-        if (array_key_exists($key, $this->cache)) {
90
+        if (array_key_exists($key, $this->cache)){
91 91
             return $this->cache[$key];
92 92
         }
93 93
 
94 94
         $this->cache[$key] = [];
95
-        try {
95
+        try{
96 96
             $method = new \ReflectionMethod($controller, $action);
97
-        } catch (\ReflectionException $e) {
97
+        }catch (\ReflectionException $e){
98 98
             return [];
99 99
         }
100 100
 
101
-        foreach ($method->getParameters() as $parameter) {
101
+        foreach ($method->getParameters() as $parameter){
102 102
             $class = $this->getParameterClass($parameter);
103 103
 
104
-            if ($class === null) {
104
+            if ($class === null){
105 105
                 continue;
106 106
             }
107 107
 
108
-            if ($class->implementsInterface(FilterInterface::class)) {
108
+            if ($class->implementsInterface(FilterInterface::class)){
109 109
                 $this->buildCache($parameter, $class, $key);
110 110
             }
111 111
         }
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $type = $parameter->getType();
125 125
 
126
-        if (!$type instanceof \ReflectionNamedType) {
126
+        if (!$type instanceof \ReflectionNamedType){
127 127
             return null;
128 128
         }
129 129
 
130
-        if ($type->isBuiltin()) {
130
+        if ($type->isBuiltin()){
131 131
             return null;
132 132
         }
133 133
 
Please login to merge, or discard this patch.
src/Framework/Domain/FilterWithRendererInterceptor.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         ReaderInterface $reader,
31 31
         ?RenderErrorsInterface $renderErrors = null,
32 32
         int $strategy = self::STRATEGY_JSON_RESPONSE
33
-    ) {
33
+    ){
34 34
         parent::__construct($container, $strategy, $renderErrors);
35 35
 
36 36
         $this->reader = $reader;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     {
44 44
         $filterClass = get_class($filter);
45 45
 
46
-        if (isset($this->renderersCache[$filterClass])) {
46
+        if (isset($this->renderersCache[$filterClass])){
47 47
             return $this->renderersCache[$filterClass]->render($filter);
48 48
         }
49 49
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         parent::buildCache($parameter, $class, $key);
56 56
 
57
-        if (null !== ($renderWith = $this->reader->firstClassMetadata($class, RenderWith::class))) {
57
+        if (null !== ($renderWith = $this->reader->firstClassMetadata($class, RenderWith::class))){
58 58
             $this->renderersCache[$class->getName()] = $this->container->get($renderWith->getRenderer());
59 59
         }
60 60
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
43 43
     {
44 44
         $filterClass = get_class($filter);
45 45
 
46
-        if (isset($this->renderersCache[$filterClass])) {
46
+        if (isset($this->renderersCache[$filterClass]))
47
+        {
47 48
             return $this->renderersCache[$filterClass]->render($filter);
48 49
         }
49 50
 
@@ -54,7 +55,8 @@  discard block
 block discarded – undo
54 55
     {
55 56
         parent::buildCache($parameter, $class, $key);
56 57
 
57
-        if (null !== ($renderWith = $this->reader->firstClassMetadata($class, RenderWith::class))) {
58
+        if (null !== ($renderWith = $this->reader->firstClassMetadata($class, RenderWith::class)))
59
+        {
58 60
             $this->renderersCache[$class->getName()] = $this->container->get($renderWith->getRenderer());
59 61
         }
60 62
     }
Please login to merge, or discard this patch.