Passed
Pull Request — master (#1196)
by Abdul Malik
11:01
created
src/Http/src/Middleware/ErrorHandlerMiddleware.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         private readonly ResponseFactoryInterface $responseFactory,
33 33
         private readonly ExceptionHandlerInterface $errorHandler,
34 34
         private readonly Verbosity $verbosity = Verbosity::VERBOSE,
35
-    ) {
35
+    ){
36 36
     }
37 37
 
38 38
     /**
@@ -41,17 +41,17 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function process(Request $request, Handler $handler): Response
43 43
     {
44
-        try {
44
+        try{
45 45
             return $handler->handle($request);
46
-        } catch (ClientException|RouterException $e) {
46
+        }catch (ClientException | RouterException $e){
47 47
             $code = $e instanceof ClientException ? $e->getCode() : 404;
48
-        } catch (\Throwable $e) {
48
+        }catch (\Throwable $e){
49 49
             $code = 500;
50 50
         }
51 51
 
52 52
         $this->errorHandler->report($e);
53 53
 
54
-        if (!$this->suppressErrors->suppressed()) {
54
+        if (!$this->suppressErrors->suppressed()){
55 55
             return $this->renderError($request, $e, $code);
56 56
         }
57 57
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 
70 70
         [$format, $renderer] = $this->getRenderer($this->errorHandler, $request);
71 71
 
72
-        if ($format !== null) {
73
-            $response = $response->withHeader('Content-Type', $format . '; charset=UTF-8');
72
+        if ($format !== null){
73
+            $response = $response->withHeader('Content-Type', $format.'; charset=UTF-8');
74 74
         }
75 75
 
76 76
         $response->getBody()->write(
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
      */
90 90
     private function getRenderer(ExceptionHandlerInterface $handler, Request $request): array
91 91
     {
92
-        if ($request->hasHeader('Accept')) {
92
+        if ($request->hasHeader('Accept')){
93 93
             $acceptItems = AcceptHeader::fromString($request->getHeaderLine('Accept'))->getAll();
94
-            foreach ($acceptItems as $item) {
94
+            foreach ($acceptItems as $item){
95 95
                 $format = $item->getValue();
96 96
                 $renderer = $handler->getRenderer($format);
97
-                if ($renderer instanceof \Spiral\Exceptions\ExceptionRendererInterface) {
97
+                if ($renderer instanceof \Spiral\Exceptions\ExceptionRendererInterface){
98 98
                     return [$format, $renderer];
99 99
                 }
100 100
             }
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,17 +41,23 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function process(Request $request, Handler $handler): Response
43 43
     {
44
-        try {
44
+        try
45
+        {
45 46
             return $handler->handle($request);
46
-        } catch (ClientException|RouterException $e) {
47
+        }
48
+        catch (ClientException|RouterException $e)
49
+        {
47 50
             $code = $e instanceof ClientException ? $e->getCode() : 404;
48
-        } catch (\Throwable $e) {
51
+        }
52
+        catch (\Throwable $e)
53
+        {
49 54
             $code = 500;
50 55
         }
51 56
 
52 57
         $this->errorHandler->report($e);
53 58
 
54
-        if (!$this->suppressErrors->suppressed()) {
59
+        if (!$this->suppressErrors->suppressed())
60
+        {
55 61
             return $this->renderError($request, $e, $code);
56 62
         }
57 63
 
@@ -69,7 +75,8 @@  discard block
 block discarded – undo
69 75
 
70 76
         [$format, $renderer] = $this->getRenderer($this->errorHandler, $request);
71 77
 
72
-        if ($format !== null) {
78
+        if ($format !== null)
79
+        {
73 80
             $response = $response->withHeader('Content-Type', $format . '; charset=UTF-8');
74 81
         }
75 82
 
@@ -89,12 +96,15 @@  discard block
 block discarded – undo
89 96
      */
90 97
     private function getRenderer(ExceptionHandlerInterface $handler, Request $request): array
91 98
     {
92
-        if ($request->hasHeader('Accept')) {
99
+        if ($request->hasHeader('Accept'))
100
+        {
93 101
             $acceptItems = AcceptHeader::fromString($request->getHeaderLine('Accept'))->getAll();
94
-            foreach ($acceptItems as $item) {
102
+            foreach ($acceptItems as $item)
103
+            {
95 104
                 $format = $item->getValue();
96 105
                 $renderer = $handler->getRenderer($format);
97
-                if ($renderer instanceof \Spiral\Exceptions\ExceptionRendererInterface) {
106
+                if ($renderer instanceof \Spiral\Exceptions\ExceptionRendererInterface)
107
+                {
98 108
                     return [$format, $renderer];
99 109
                 }
100 110
             }
Please login to merge, or discard this patch.
src/Http/src/LazyPipeline.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     public function __construct(
40 40
         #[Proxy] private readonly ContainerInterface $container,
41 41
         private readonly ?EventDispatcherInterface $dispatcher = null,
42
-    ) {
42
+    ){
43 43
     }
44 44
 
45 45
     /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @param MiddlewareInterface ...$middleware List of middleware or its definition.
49 49
      */
50
-    public function withAddedMiddleware(MiddlewareInterface|Autowire|string ...$middleware): self
50
+    public function withAddedMiddleware(MiddlewareInterface | Autowire | string ...$middleware): self
51 51
     {
52 52
         $pipeline = clone $this;
53 53
         $pipeline->middleware = \array_merge($pipeline->middleware, $middleware);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      *
60 60
      * @param MiddlewareInterface ...$middleware List of middleware or its definition.
61 61
      */
62
-    public function withMiddleware(MiddlewareInterface|Autowire|string ...$middleware): self
62
+    public function withMiddleware(MiddlewareInterface | Autowire | string ...$middleware): self
63 63
     {
64 64
         $pipeline = clone $this;
65 65
         $pipeline->middleware = $middleware;
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 
93 93
         $previousRequest = $currentRequest->get();
94 94
         $currentRequest->set($request);
95
-        try {
95
+        try{
96 96
             // There is no middleware to process, let's pass the request to the handler
97
-            if (!\array_key_exists($this->position, $this->middleware)) {
97
+            if (!\array_key_exists($this->position, $this->middleware)){
98 98
                 return $this->handler->handle($request);
99 99
             }
100 100
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                 ? \sprintf('%s=%s', $this->middleware[$this->position], $middleware::class)
109 109
                 : $middleware::class;
110 110
             // Init a tracing span when the pipeline starts
111
-            if (!$span instanceof \Spiral\Telemetry\SpanInterface) {
111
+            if (!$span instanceof \Spiral\Telemetry\SpanInterface){
112 112
                 /** @var TracerInterface $tracer */
113 113
                 $tracer = $this->container->get(TracerInterface::class);
114 114
                 return $tracer->trace(
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             $span->setAttribute('http.middleware', $middlewares);
127 127
 
128 128
             return $middleware->process($request, $this->next($span));
129
-        } finally {
129
+        }finally{
130 130
             $currentRequest->set($previousRequest);
131 131
         }
132 132
     }
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,9 +92,11 @@  discard block
 block discarded – undo
92 92
 
93 93
         $previousRequest = $currentRequest->get();
94 94
         $currentRequest->set($request);
95
-        try {
95
+        try
96
+        {
96 97
             // There is no middleware to process, let's pass the request to the handler
97
-            if (!\array_key_exists($this->position, $this->middleware)) {
98
+            if (!\array_key_exists($this->position, $this->middleware))
99
+            {
98 100
                 return $this->handler->handle($request);
99 101
             }
100 102
 
@@ -108,7 +110,8 @@  discard block
 block discarded – undo
108 110
                 ? \sprintf('%s=%s', $this->middleware[$this->position], $middleware::class)
109 111
                 : $middleware::class;
110 112
             // Init a tracing span when the pipeline starts
111
-            if (!$span instanceof \Spiral\Telemetry\SpanInterface) {
113
+            if (!$span instanceof \Spiral\Telemetry\SpanInterface)
114
+            {
112 115
                 /** @var TracerInterface $tracer */
113 116
                 $tracer = $this->container->get(TracerInterface::class);
114 117
                 return $tracer->trace(
@@ -126,7 +129,9 @@  discard block
 block discarded – undo
126 129
             $span->setAttribute('http.middleware', $middlewares);
127 130
 
128 131
             return $middleware->process($request, $this->next($span));
129
-        } finally {
132
+        }
133
+        finally
134
+        {
130 135
             $currentRequest->set($previousRequest);
131 136
         }
132 137
     }
Please login to merge, or discard this patch.
src/Logger/src/Traits/LoggerTrait.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
      */
30 30
     protected function getLogger(?string $channel = null): LoggerInterface
31 31
     {
32
-        if ($channel !== null) {
32
+        if ($channel !== null){
33 33
             return $this->allocateLogger($channel);
34 34
         }
35 35
 
36
-        if ($this->logger !== null) {
36
+        if ($this->logger !== null){
37 37
             return $this->logger;
38 38
         }
39 39
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     private function allocateLogger(string $channel): LoggerInterface
48 48
     {
49 49
         $container = ContainerScope::getContainer();
50
-        if (!$container instanceof \Psr\Container\ContainerInterface || !$container->has(LogsInterface::class)) {
50
+        if (!$container instanceof \Psr\Container\ContainerInterface || !$container->has(LogsInterface::class)){
51 51
             return $this->logger ?? new NullLogger();
52 52
         }
53 53
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,11 +29,13 @@  discard block
 block discarded – undo
29 29
      */
30 30
     protected function getLogger(?string $channel = null): LoggerInterface
31 31
     {
32
-        if ($channel !== null) {
32
+        if ($channel !== null)
33
+        {
33 34
             return $this->allocateLogger($channel);
34 35
         }
35 36
 
36
-        if ($this->logger !== null) {
37
+        if ($this->logger !== null)
38
+        {
37 39
             return $this->logger;
38 40
         }
39 41
 
@@ -47,7 +49,8 @@  discard block
 block discarded – undo
47 49
     private function allocateLogger(string $channel): LoggerInterface
48 50
     {
49 51
         $container = ContainerScope::getContainer();
50
-        if (!$container instanceof \Psr\Container\ContainerInterface || !$container->has(LogsInterface::class)) {
52
+        if (!$container instanceof \Psr\Container\ContainerInterface || !$container->has(LogsInterface::class))
53
+        {
51 54
             return $this->logger ?? new NullLogger();
52 55
         }
53 56
 
Please login to merge, or discard this patch.
src/Scaffolder/src/Declaration/ConfigDeclaration.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         protected ?string $comment = null,
35 35
         private readonly string $directory = '',
36 36
         ?string $namespace = null,
37
-    ) {
37
+    ){
38 38
         parent::__construct($config, $name, $comment, $namespace);
39 39
     }
40 40
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
         $this->class->addConstant('CONFIG', $configName)->setPublic();
44 44
 
45 45
         $filename = $this->makeConfigFilename($configName);
46
-        if ($reverse) {
47
-            if (!$this->files->exists($filename)) {
46
+        if ($reverse){
47
+            if (!$this->files->exists($filename)){
48 48
                 throw new ScaffolderException(\sprintf("Config filename %s doesn't exist", $filename));
49 49
             }
50 50
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             $this->declareGetters($defaultsFromFile);
53 53
 
54 54
             $this->class->getProperty('config')->setValue($this->defaultValues->get($defaultsFromFile));
55
-        } elseif (!$this->files->exists($filename)) {
55
+        } elseif (!$this->files->exists($filename)){
56 56
             $this->touchConfigFile($filename);
57 57
         }
58 58
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
         $this->files->write(
110 110
             $filename,
111
-            $file->render() . PHP_EOL . (new Dumper())->dump(new Literal('return [];')),
111
+            $file->render().PHP_EOL.(new Dumper())->dump(new Literal('return [];')),
112 112
             FilesInterface::READONLY,
113 113
             true,
114 114
         );
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         $getters = [];
127 127
         $gettersByKey = [];
128 128
 
129
-        foreach ($defaults as $key => $value) {
129
+        foreach ($defaults as $key => $value){
130 130
             $key = (string)$key;
131 131
             $getter = $this->makeGetterName($key);
132 132
             $getters[] = $getter;
@@ -134,19 +134,19 @@  discard block
 block discarded – undo
134 134
             $method = $this->class->addMethod($getter)->setPublic();
135 135
             $method->setBody(\sprintf('return $this->config[\'%s\'];', $key));
136 136
 
137
-            if (\is_array($value)) {
137
+            if (\is_array($value)){
138 138
                 $gettersByKey[] = ['key' => $key, 'value' => $value];
139 139
             }
140 140
 
141 141
             $returnTypeHint = $this->typeHints->getHint(\gettype($value));
142
-            if ($returnTypeHint !== null) {
142
+            if ($returnTypeHint !== null){
143 143
                 $method->setReturnType($returnTypeHint);
144 144
             }
145 145
         }
146 146
 
147
-        foreach ($gettersByKey as $item) {
147
+        foreach ($gettersByKey as $item){
148 148
             $method = $this->declareGettersByKey($getters, $item['key'], $item['value']);
149
-            if ($method instanceof \Spiral\Reactor\Partial\Method) {
149
+            if ($method instanceof \Spiral\Reactor\Partial\Method){
150 150
                 $getters[] = $method->getName();
151 151
             }
152 152
         }
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
     private function declareGettersByKey(array $methodNames, string $key, array $value): ?Method
156 156
     {
157 157
         //Won't create if there's less than 2 sub-items
158
-        if (\count($value) < 2) {
158
+        if (\count($value) < 2){
159 159
             return null;
160 160
         }
161 161
 
162 162
         $singularKey = $this->singularize($key);
163 163
         $name = $this->makeGetterName($singularKey);
164
-        if (\in_array($name, $methodNames, true)) {
164
+        if (\in_array($name, $methodNames, true)){
165 165
             $name = $this->makeGetterName($singularKey, 'get', 'by');
166 166
         }
167 167
 
168 168
         //Name conflict, won't merge
169
-        if (\in_array($name, $methodNames, true)) {
169
+        if (\in_array($name, $methodNames, true)){
170 170
             return null;
171 171
         }
172 172
 
173 173
         $keyType = defineArrayType(\array_keys($value), '-mixed-');
174 174
         $valueType = defineArrayType(\array_values($value), '-mixed-');
175 175
         //We need a fixed structure here
176
-        if ($keyType === '-mixed-' || $valueType === '-mixed-') {
176
+        if ($keyType === '-mixed-' || $valueType === '-mixed-'){
177 177
             return null;
178 178
         }
179 179
 
180 180
         //Won't create for associated arrays
181
-        if ($this->typeAnnotations->mapType($keyType) === 'int' && \array_is_list($value)) {
181
+        if ($this->typeAnnotations->mapType($keyType) === 'int' && \array_is_list($value)){
182 182
             return null;
183 183
         }
184 184
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
         $param = $method->addParameter($singularKey);
190 190
         $paramTypeHint = $this->typeHints->getHint($keyType);
191
-        if ($paramTypeHint !== null) {
191
+        if ($paramTypeHint !== null){
192 192
             $param->setType($paramTypeHint);
193 193
         }
194 194
 
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
     private function makeGetterName(string $name, string $prefix = 'get', string $postfix = ''): string
199 199
     {
200 200
         $chunks = [];
201
-        if (!empty($prefix)) {
201
+        if (!empty($prefix)){
202 202
             $chunks[] = $prefix;
203 203
         }
204 204
 
205 205
         $name = $this->slugify->slugify($name, ['lowercase' => false]);
206 206
         $chunks[] = \count($chunks) !== 0 ? $this->classify($name) : $name;
207
-        if (!empty($postfix)) {
207
+        if (!empty($postfix)){
208 208
             $chunks[] = \ucfirst($postfix);
209 209
         }
210 210
 
Please login to merge, or discard this patch.
Braces   +33 added lines, -16 removed lines patch added patch discarded remove patch
@@ -43,8 +43,10 @@  discard block
 block discarded – undo
43 43
         $this->class->addConstant('CONFIG', $configName)->setPublic();
44 44
 
45 45
         $filename = $this->makeConfigFilename($configName);
46
-        if ($reverse) {
47
-            if (!$this->files->exists($filename)) {
46
+        if ($reverse)
47
+        {
48
+            if (!$this->files->exists($filename))
49
+            {
48 50
                 throw new ScaffolderException(\sprintf("Config filename %s doesn't exist", $filename));
49 51
             }
50 52
 
@@ -52,7 +54,9 @@  discard block
 block discarded – undo
52 54
             $this->declareGetters($defaultsFromFile);
53 55
 
54 56
             $this->class->getProperty('config')->setValue($this->defaultValues->get($defaultsFromFile));
55
-        } elseif (!$this->files->exists($filename)) {
57
+        }
58
+        elseif (!$this->files->exists($filename))
59
+        {
56 60
             $this->touchConfigFile($filename);
57 61
         }
58 62
     }
@@ -126,7 +130,8 @@  discard block
 block discarded – undo
126 130
         $getters = [];
127 131
         $gettersByKey = [];
128 132
 
129
-        foreach ($defaults as $key => $value) {
133
+        foreach ($defaults as $key => $value)
134
+        {
130 135
             $key = (string)$key;
131 136
             $getter = $this->makeGetterName($key);
132 137
             $getters[] = $getter;
@@ -134,19 +139,23 @@  discard block
 block discarded – undo
134 139
             $method = $this->class->addMethod($getter)->setPublic();
135 140
             $method->setBody(\sprintf('return $this->config[\'%s\'];', $key));
136 141
 
137
-            if (\is_array($value)) {
142
+            if (\is_array($value))
143
+            {
138 144
                 $gettersByKey[] = ['key' => $key, 'value' => $value];
139 145
             }
140 146
 
141 147
             $returnTypeHint = $this->typeHints->getHint(\gettype($value));
142
-            if ($returnTypeHint !== null) {
148
+            if ($returnTypeHint !== null)
149
+            {
143 150
                 $method->setReturnType($returnTypeHint);
144 151
             }
145 152
         }
146 153
 
147
-        foreach ($gettersByKey as $item) {
154
+        foreach ($gettersByKey as $item)
155
+        {
148 156
             $method = $this->declareGettersByKey($getters, $item['key'], $item['value']);
149
-            if ($method instanceof \Spiral\Reactor\Partial\Method) {
157
+            if ($method instanceof \Spiral\Reactor\Partial\Method)
158
+            {
150 159
                 $getters[] = $method->getName();
151 160
             }
152 161
         }
@@ -155,30 +164,35 @@  discard block
 block discarded – undo
155 164
     private function declareGettersByKey(array $methodNames, string $key, array $value): ?Method
156 165
     {
157 166
         //Won't create if there's less than 2 sub-items
158
-        if (\count($value) < 2) {
167
+        if (\count($value) < 2)
168
+        {
159 169
             return null;
160 170
         }
161 171
 
162 172
         $singularKey = $this->singularize($key);
163 173
         $name = $this->makeGetterName($singularKey);
164
-        if (\in_array($name, $methodNames, true)) {
174
+        if (\in_array($name, $methodNames, true))
175
+        {
165 176
             $name = $this->makeGetterName($singularKey, 'get', 'by');
166 177
         }
167 178
 
168 179
         //Name conflict, won't merge
169
-        if (\in_array($name, $methodNames, true)) {
180
+        if (\in_array($name, $methodNames, true))
181
+        {
170 182
             return null;
171 183
         }
172 184
 
173 185
         $keyType = defineArrayType(\array_keys($value), '-mixed-');
174 186
         $valueType = defineArrayType(\array_values($value), '-mixed-');
175 187
         //We need a fixed structure here
176
-        if ($keyType === '-mixed-' || $valueType === '-mixed-') {
188
+        if ($keyType === '-mixed-' || $valueType === '-mixed-')
189
+        {
177 190
             return null;
178 191
         }
179 192
 
180 193
         //Won't create for associated arrays
181
-        if ($this->typeAnnotations->mapType($keyType) === 'int' && \array_is_list($value)) {
194
+        if ($this->typeAnnotations->mapType($keyType) === 'int' && \array_is_list($value))
195
+        {
182 196
             return null;
183 197
         }
184 198
 
@@ -188,7 +202,8 @@  discard block
 block discarded – undo
188 202
 
189 203
         $param = $method->addParameter($singularKey);
190 204
         $paramTypeHint = $this->typeHints->getHint($keyType);
191
-        if ($paramTypeHint !== null) {
205
+        if ($paramTypeHint !== null)
206
+        {
192 207
             $param->setType($paramTypeHint);
193 208
         }
194 209
 
@@ -198,13 +213,15 @@  discard block
 block discarded – undo
198 213
     private function makeGetterName(string $name, string $prefix = 'get', string $postfix = ''): string
199 214
     {
200 215
         $chunks = [];
201
-        if (!empty($prefix)) {
216
+        if (!empty($prefix))
217
+        {
202 218
             $chunks[] = $prefix;
203 219
         }
204 220
 
205 221
         $name = $this->slugify->slugify($name, ['lowercase' => false]);
206 222
         $chunks[] = \count($chunks) !== 0 ? $this->classify($name) : $name;
207
-        if (!empty($postfix)) {
223
+        if (!empty($postfix))
224
+        {
208 225
             $chunks[] = \ucfirst($postfix);
209 226
         }
210 227
 
Please login to merge, or discard this patch.
src/Tokenizer/src/InterfaceLocator.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public const INJECTOR = InterfaceLocatorInjector::class;
15 15
 
16
-    public function getInterfaces(string|null $target = null): array
16
+    public function getInterfaces(string | null $target = null): array
17 17
     {
18
-        if (!empty($target)) {
18
+        if (!empty($target)){
19 19
             $target = new \ReflectionClass($target);
20 20
         }
21 21
 
22 22
         $result = [];
23
-        foreach ($this->availableInterfaces() as $interface) {
24
-            try {
23
+        foreach ($this->availableInterfaces() as $interface){
24
+            try{
25 25
                 $reflection = $this->classReflection($interface);
26
-            } catch (LocatorException $e) {
27
-                if ($this->debug) {
26
+            }catch (LocatorException $e){
27
+                if ($this->debug){
28 28
                     throw $e;
29 29
                 }
30 30
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
                 continue;
33 33
             }
34 34
 
35
-            if (!$this->isTargeted($reflection, $target)) {
35
+            if (!$this->isTargeted($reflection, $target)){
36 36
                 continue;
37 37
             }
38 38
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $interfaces = [];
53 53
 
54
-        foreach ($this->availableReflections() as $reflection) {
54
+        foreach ($this->availableReflections() as $reflection){
55 55
             $interfaces = \array_merge($interfaces, $reflection->getInterfaces());
56 56
         }
57 57
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool
65 65
     {
66
-        if (!$target instanceof \ReflectionClass) {
66
+        if (!$target instanceof \ReflectionClass){
67 67
             return true;
68 68
         }
69 69
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,16 +15,22 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function getInterfaces(string|null $target = null): array
17 17
     {
18
-        if (!empty($target)) {
18
+        if (!empty($target))
19
+        {
19 20
             $target = new \ReflectionClass($target);
20 21
         }
21 22
 
22 23
         $result = [];
23
-        foreach ($this->availableInterfaces() as $interface) {
24
-            try {
24
+        foreach ($this->availableInterfaces() as $interface)
25
+        {
26
+            try
27
+            {
25 28
                 $reflection = $this->classReflection($interface);
26
-            } catch (LocatorException $e) {
27
-                if ($this->debug) {
29
+            }
30
+            catch (LocatorException $e)
31
+            {
32
+                if ($this->debug)
33
+                {
28 34
                     throw $e;
29 35
                 }
30 36
 
@@ -32,7 +38,8 @@  discard block
 block discarded – undo
32 38
                 continue;
33 39
             }
34 40
 
35
-            if (!$this->isTargeted($reflection, $target)) {
41
+            if (!$this->isTargeted($reflection, $target))
42
+            {
36 43
                 continue;
37 44
             }
38 45
 
@@ -51,7 +58,8 @@  discard block
 block discarded – undo
51 58
     {
52 59
         $interfaces = [];
53 60
 
54
-        foreach ($this->availableReflections() as $reflection) {
61
+        foreach ($this->availableReflections() as $reflection)
62
+        {
55 63
             $interfaces = \array_merge($interfaces, $reflection->getInterfaces());
56 64
         }
57 65
 
@@ -63,7 +71,8 @@  discard block
 block discarded – undo
63 71
      */
64 72
     protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool
65 73
     {
66
-        if (!$target instanceof \ReflectionClass) {
74
+        if (!$target instanceof \ReflectionClass)
75
+        {
67 76
             return true;
68 77
         }
69 78
 
Please login to merge, or discard this patch.
src/Tokenizer/src/EnumLocator.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public const INJECTOR = EnumLocatorInjector::class;
15 15
 
16
-    public function getEnums(object|string|null $target = null): array
16
+    public function getEnums(object | string | null $target = null): array
17 17
     {
18
-        if (!empty($target)) {
18
+        if (!empty($target)){
19 19
             $target = new \ReflectionClass($target);
20 20
         }
21 21
 
22 22
         $result = [];
23
-        foreach ($this->availableEnums() as $enum) {
24
-            try {
23
+        foreach ($this->availableEnums() as $enum){
24
+            try{
25 25
                 $reflection = $this->enumReflection($enum);
26
-            } catch (LocatorException $e) {
27
-                if ($this->debug) {
26
+            }catch (LocatorException $e){
27
+                if ($this->debug){
28 28
                     throw $e;
29 29
                 }
30 30
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
                 continue;
33 33
             }
34 34
 
35
-            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) {
35
+            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()){
36 36
                 continue;
37 37
             }
38 38
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $enums = [];
53 53
 
54
-        foreach ($this->availableReflections() as $reflection) {
54
+        foreach ($this->availableReflections() as $reflection){
55 55
             $enums = \array_merge($enums, $reflection->getEnums());
56 56
         }
57 57
 
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected function isTargeted(\ReflectionEnum $enum, ?\ReflectionClass $target = null): bool
65 65
     {
66
-        if (!$target instanceof \ReflectionClass) {
66
+        if (!$target instanceof \ReflectionClass){
67 67
             return true;
68 68
         }
69 69
 
70
-        if (!$target->isTrait()) {
70
+        if (!$target->isTrait()){
71 71
             //Target is interface or class
72 72
             /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */
73 73
             return $enum->isSubclassOf($target) || $enum->getName() === $target->getName();
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,16 +15,22 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function getEnums(object|string|null $target = null): array
17 17
     {
18
-        if (!empty($target)) {
18
+        if (!empty($target))
19
+        {
19 20
             $target = new \ReflectionClass($target);
20 21
         }
21 22
 
22 23
         $result = [];
23
-        foreach ($this->availableEnums() as $enum) {
24
-            try {
24
+        foreach ($this->availableEnums() as $enum)
25
+        {
26
+            try
27
+            {
25 28
                 $reflection = $this->enumReflection($enum);
26
-            } catch (LocatorException $e) {
27
-                if ($this->debug) {
29
+            }
30
+            catch (LocatorException $e)
31
+            {
32
+                if ($this->debug)
33
+                {
28 34
                     throw $e;
29 35
                 }
30 36
 
@@ -32,7 +38,8 @@  discard block
 block discarded – undo
32 38
                 continue;
33 39
             }
34 40
 
35
-            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) {
41
+            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface())
42
+            {
36 43
                 continue;
37 44
             }
38 45
 
@@ -51,7 +58,8 @@  discard block
 block discarded – undo
51 58
     {
52 59
         $enums = [];
53 60
 
54
-        foreach ($this->availableReflections() as $reflection) {
61
+        foreach ($this->availableReflections() as $reflection)
62
+        {
55 63
             $enums = \array_merge($enums, $reflection->getEnums());
56 64
         }
57 65
 
@@ -63,11 +71,13 @@  discard block
 block discarded – undo
63 71
      */
64 72
     protected function isTargeted(\ReflectionEnum $enum, ?\ReflectionClass $target = null): bool
65 73
     {
66
-        if (!$target instanceof \ReflectionClass) {
74
+        if (!$target instanceof \ReflectionClass)
75
+        {
67 76
             return true;
68 77
         }
69 78
 
70
-        if (!$target->isTrait()) {
79
+        if (!$target->isTrait())
80
+        {
71 81
             //Target is interface or class
72 82
             /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */
73 83
             return $enum->isSubclassOf($target) || $enum->getName() === $target->getName();
Please login to merge, or discard this patch.
src/Tokenizer/src/ClassLocator.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public const INJECTOR = ClassLocatorInjector::class;
15 15
 
16
-    public function getClasses(object|string|null $target = null): array
16
+    public function getClasses(object | string | null $target = null): array
17 17
     {
18
-        if (!empty($target)) {
18
+        if (!empty($target)){
19 19
             $target = new \ReflectionClass($target);
20 20
         }
21 21
 
22 22
         $result = [];
23
-        foreach ($this->availableClasses() as $class) {
24
-            try {
23
+        foreach ($this->availableClasses() as $class){
24
+            try{
25 25
                 $reflection = $this->classReflection($class);
26
-            } catch (LocatorException $e) {
27
-                if ($this->debug) {
26
+            }catch (LocatorException $e){
27
+                if ($this->debug){
28 28
                     throw $e;
29 29
                 }
30 30
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
                 continue;
33 33
             }
34 34
 
35
-            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) {
35
+            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()){
36 36
                 continue;
37 37
             }
38 38
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $classes = [];
53 53
 
54
-        foreach ($this->availableReflections() as $reflection) {
54
+        foreach ($this->availableReflections() as $reflection){
55 55
             $classes = \array_merge($classes, $reflection->getClasses());
56 56
         }
57 57
 
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool
65 65
     {
66
-        if (!$target instanceof \ReflectionClass) {
66
+        if (!$target instanceof \ReflectionClass){
67 67
             return true;
68 68
         }
69 69
 
70
-        if (!$target->isTrait()) {
70
+        if (!$target->isTrait()){
71 71
             //Target is interface or class
72 72
             return $class->isSubclassOf($target) || $class->getName() === $target->getName();
73 73
         }
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,16 +15,22 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function getClasses(object|string|null $target = null): array
17 17
     {
18
-        if (!empty($target)) {
18
+        if (!empty($target))
19
+        {
19 20
             $target = new \ReflectionClass($target);
20 21
         }
21 22
 
22 23
         $result = [];
23
-        foreach ($this->availableClasses() as $class) {
24
-            try {
24
+        foreach ($this->availableClasses() as $class)
25
+        {
26
+            try
27
+            {
25 28
                 $reflection = $this->classReflection($class);
26
-            } catch (LocatorException $e) {
27
-                if ($this->debug) {
29
+            }
30
+            catch (LocatorException $e)
31
+            {
32
+                if ($this->debug)
33
+                {
28 34
                     throw $e;
29 35
                 }
30 36
 
@@ -32,7 +38,8 @@  discard block
 block discarded – undo
32 38
                 continue;
33 39
             }
34 40
 
35
-            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) {
41
+            if (!$this->isTargeted($reflection, $target) || $reflection->isInterface())
42
+            {
36 43
                 continue;
37 44
             }
38 45
 
@@ -51,7 +58,8 @@  discard block
 block discarded – undo
51 58
     {
52 59
         $classes = [];
53 60
 
54
-        foreach ($this->availableReflections() as $reflection) {
61
+        foreach ($this->availableReflections() as $reflection)
62
+        {
55 63
             $classes = \array_merge($classes, $reflection->getClasses());
56 64
         }
57 65
 
@@ -63,11 +71,13 @@  discard block
 block discarded – undo
63 71
      */
64 72
     protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool
65 73
     {
66
-        if (!$target instanceof \ReflectionClass) {
74
+        if (!$target instanceof \ReflectionClass)
75
+        {
67 76
             return true;
68 77
         }
69 78
 
70
-        if (!$target->isTrait()) {
79
+        if (!$target->isTrait())
80
+        {
71 81
             //Target is interface or class
72 82
             return $class->isSubclassOf($target) || $class->getName() === $target->getName();
73 83
         }
Please login to merge, or discard this patch.
src/AuthHttp/src/Transport/CookieTransport.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
         private readonly bool $secure = false,
23 23
         private readonly bool $httpOnly = true,
24 24
         private readonly ?string $sameSite = null
25
-    ) {
25
+    ){
26 26
     }
27 27
 
28 28
     public function fetchToken(Request $request): ?string
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     ): Response {
40 40
         /** @var CookieQueue $cookieQueue */
41 41
         $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE);
42
-        if ($cookieQueue === null) {
42
+        if ($cookieQueue === null){
43 43
             return $response->withAddedHeader(
44 44
                 'Set-Cookie',
45 45
                 Cookie::create(
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
             );
56 56
         }
57 57
 
58
-        if ($tokenID === null) {
58
+        if ($tokenID === null){
59 59
             $cookieQueue->delete($this->cookie);
60
-        } else {
60
+        }else{
61 61
             $cookieQueue->set(
62 62
                 $this->cookie,
63 63
                 $tokenID,
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     private function getLifetime(?\DateTimeInterface $expiresAt = null): ?int
86 86
     {
87
-        if (!$expiresAt instanceof \DateTimeInterface) {
87
+        if (!$expiresAt instanceof \DateTimeInterface){
88 88
             return null;
89 89
         }
90 90
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,7 +39,8 @@  discard block
 block discarded – undo
39 39
     ): Response {
40 40
         /** @var CookieQueue $cookieQueue */
41 41
         $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE);
42
-        if ($cookieQueue === null) {
42
+        if ($cookieQueue === null)
43
+        {
43 44
             return $response->withAddedHeader(
44 45
                 'Set-Cookie',
45 46
                 Cookie::create(
@@ -55,9 +56,12 @@  discard block
 block discarded – undo
55 56
             );
56 57
         }
57 58
 
58
-        if ($tokenID === null) {
59
+        if ($tokenID === null)
60
+        {
59 61
             $cookieQueue->delete($this->cookie);
60
-        } else {
62
+        }
63
+        else
64
+        {
61 65
             $cookieQueue->set(
62 66
                 $this->cookie,
63 67
                 $tokenID,
@@ -84,7 +88,8 @@  discard block
 block discarded – undo
84 88
      */
85 89
     private function getLifetime(?\DateTimeInterface $expiresAt = null): ?int
86 90
     {
87
-        if (!$expiresAt instanceof \DateTimeInterface) {
91
+        if (!$expiresAt instanceof \DateTimeInterface)
92
+        {
88 93
             return null;
89 94
         }
90 95
 
Please login to merge, or discard this patch.
src/AuthHttp/src/Middleware/AuthMiddleware.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         private readonly TokenStorageInterface $tokenStorage,
36 36
         private readonly TransportRegistry $transportRegistry,
37 37
         private readonly ?EventDispatcherInterface $eventDispatcher = null,
38
-    ) {
38
+    ){
39 39
     }
40 40
 
41 41
     /**
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 
57 57
     private function initContext(Request $request, AuthContextInterface $authContext): AuthContextInterface
58 58
     {
59
-        foreach ($this->transportRegistry->getTransports() as $name => $transport) {
59
+        foreach ($this->transportRegistry->getTransports() as $name => $transport){
60 60
             $tokenID = $transport->fetchToken($request);
61
-            if ($tokenID === null) {
61
+            if ($tokenID === null){
62 62
                 continue;
63 63
             }
64 64
 
65 65
             $token = $this->tokenStorage->load($tokenID);
66
-            if (!$token instanceof \Spiral\Auth\TokenInterface) {
66
+            if (!$token instanceof \Spiral\Auth\TokenInterface){
67 67
                 continue;
68 68
             }
69 69
 
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
 
78 78
     private function closeContext(Request $request, Response $response, AuthContextInterface $authContext): Response
79 79
     {
80
-        if (!$authContext->getToken() instanceof \Spiral\Auth\TokenInterface) {
80
+        if (!$authContext->getToken() instanceof \Spiral\Auth\TokenInterface){
81 81
             return $response;
82 82
         }
83 83
 
84 84
         $transport = $this->transportRegistry->getTransport($authContext->getTransport());
85 85
 
86
-        if ($authContext->isClosed()) {
86
+        if ($authContext->isClosed()){
87 87
             $this->tokenStorage->delete($authContext->getToken());
88 88
 
89 89
             return $transport->removeToken(
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,14 +56,17 @@  discard block
 block discarded – undo
56 56
 
57 57
     private function initContext(Request $request, AuthContextInterface $authContext): AuthContextInterface
58 58
     {
59
-        foreach ($this->transportRegistry->getTransports() as $name => $transport) {
59
+        foreach ($this->transportRegistry->getTransports() as $name => $transport)
60
+        {
60 61
             $tokenID = $transport->fetchToken($request);
61
-            if ($tokenID === null) {
62
+            if ($tokenID === null)
63
+            {
62 64
                 continue;
63 65
             }
64 66
 
65 67
             $token = $this->tokenStorage->load($tokenID);
66
-            if (!$token instanceof \Spiral\Auth\TokenInterface) {
68
+            if (!$token instanceof \Spiral\Auth\TokenInterface)
69
+            {
67 70
                 continue;
68 71
             }
69 72
 
@@ -77,13 +80,15 @@  discard block
 block discarded – undo
77 80
 
78 81
     private function closeContext(Request $request, Response $response, AuthContextInterface $authContext): Response
79 82
     {
80
-        if (!$authContext->getToken() instanceof \Spiral\Auth\TokenInterface) {
83
+        if (!$authContext->getToken() instanceof \Spiral\Auth\TokenInterface)
84
+        {
81 85
             return $response;
82 86
         }
83 87
 
84 88
         $transport = $this->transportRegistry->getTransport($authContext->getTransport());
85 89
 
86
-        if ($authContext->isClosed()) {
90
+        if ($authContext->isClosed())
91
+        {
87 92
             $this->tokenStorage->delete($authContext->getToken());
88 93
 
89 94
             return $transport->removeToken(
Please login to merge, or discard this patch.