Passed
Push — master ( e1a877...53fca2 )
by Aleksei
14:14 queued 02:22
created
src/Core/src/Internal/Proxy/ProxyClassRenderer.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -27,29 +27,29 @@  discard block
 block discarded – undo
27 27
             MagicCallTrait::class,
28 28
         ] : [];
29 29
 
30
-        if (\str_contains($className, '\\')) {
30
+        if (\str_contains($className, '\\')){
31 31
             $classShortName = \substr($className, \strrpos($className, '\\') + 1);
32
-            $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';';
33
-        } else {
32
+            $classNamespaceStr = 'namespace '.\substr($className, 0, \strrpos($className, '\\')).';';
33
+        }else{
34 34
             $classShortName = $className;
35 35
             $classNamespaceStr = '';
36 36
         }
37 37
 
38 38
         $interface = $type->getName();
39 39
         $classBody = [];
40
-        foreach ($type->getMethods() as $method) {
41
-            if ($method->isConstructor()) {
40
+        foreach ($type->getMethods() as $method){
41
+            if ($method->isConstructor()){
42 42
                 throw new \LogicException('Constructor is not allowed in a proxy.');
43 43
             }
44 44
 
45
-            if ($method->isDestructor()) {
45
+            if ($method->isDestructor()){
46 46
                 $classBody[] = self::renderMethod($method);
47 47
                 continue;
48 48
             }
49 49
 
50 50
             $hasRefs = false;
51
-            $return = $method->hasReturnType() && (string) $method->getReturnType() === 'void' ? '' : 'return ';
52
-            $call = ($method->isStatic() ? '::' : '->') . $method->getName();
51
+            $return = $method->hasReturnType() && (string)$method->getReturnType() === 'void' ? '' : 'return ';
52
+            $call = ($method->isStatic() ? '::' : '->').$method->getName();
53 53
             $context = $method->isStatic() ? 'null' : '$this->__container_proxy_context';
54 54
             $containerStr = match (false) {
55 55
                 $attachContainer => 'null',
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
                 PHP;
70 70
 
71 71
             $args = [];
72
-            foreach ($method->getParameters() as $param) {
72
+            foreach ($method->getParameters() as $param){
73 73
                 $hasRefs = $hasRefs || $param->isPassedByReference();
74
-                $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName();
74
+                $args[] = ($param->isVariadic() ? '...' : '').'$'.$param->getName();
75 75
             }
76 76
 
77
-            if (!$hasRefs && !$method->isVariadic()) {
77
+            if (!$hasRefs && !$method->isVariadic()){
78 78
                 $classBody[] = self::renderMethod(
79 79
                     $method,
80 80
                     <<<PHP
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
             $argsStr = \implode(', ', $args);
88 88
 
89
-            if ($method->isVariadic()) {
89
+            if ($method->isVariadic()){
90 90
                 $classBody[] = self::renderMethod(
91 91
                     $method,
92 92
                     <<<PHP
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
         $traitsStr = $traits === [] ? '' : \implode(
110 110
             "\n    ",
111
-            \array_map(static fn(string $trait): string => 'use \\' . \ltrim($trait, '\\') . ';', $traits),
111
+            \array_map(static fn(string $trait) : string => 'use \\'.\ltrim($trait, '\\').';', $traits),
112 112
         );
113 113
         return <<<PHP
114 114
             $classNamespaceStr
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             $m->getName(),
132 132
             \implode(', ', \array_map(self::renderParameter(...), $m->getParameters())),
133 133
             $m->hasReturnType()
134
-                ? ': ' . self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass())
134
+                ? ': '.self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass())
135 135
                 : '',
136 136
             $body,
137 137
         );
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
                 $param->hasType() ? 'mixed' : '',
146 146
                 $param->isPassedByReference() ? '&' : '',
147 147
                 $param->isVariadic() ? '...' : '',
148
-                '$' . $param->getName(),
149
-                $param->isOptional() && !$param->isVariadic() ? ' = ' . self::renderDefaultValue($param) : '',
148
+                '$'.$param->getName(),
149
+                $param->isOptional() && !$param->isVariadic() ? ' = '.self::renderDefaultValue($param) : '',
150 150
             ),
151 151
             ' ',
152 152
         );
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
     public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string
156 156
     {
157
-        if ($types instanceof \ReflectionNamedType) {
158
-            return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin()
157
+        if ($types instanceof \ReflectionNamedType){
158
+            return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '').($types->isBuiltin()
159 159
                     ? $types->getName()
160 160
                     : self::normalizeClassType($types, $class));
161 161
         }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         };
168 168
 
169 169
         $result = [];
170
-        foreach ($types as $type) {
170
+        foreach ($types as $type){
171 171
             $result[] = $type->isBuiltin()
172 172
                 ? $type->getName()
173 173
                 : self::normalizeClassType($type, $class);
@@ -178,12 +178,12 @@  discard block
 block discarded – undo
178 178
 
179 179
     public static function renderDefaultValue(\ReflectionParameter $param): string
180 180
     {
181
-        if ($param->isDefaultValueConstant()) {
181
+        if ($param->isDefaultValueConstant()){
182 182
             $result = $param->getDefaultValueConstantName();
183 183
 
184
-            return \explode('::', (string) $result)[0] === 'self'
184
+            return \explode('::', (string)$result)[0] === 'self'
185 185
                 ? $result
186
-                : '\\' . $result;
186
+                : '\\'.$result;
187 187
         }
188 188
 
189 189
         $cut = self::cutDefaultValue($param);
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
 
196 196
     public static function normalizeClassType(\ReflectionNamedType $type, \ReflectionClass $class): string
197 197
     {
198
-        return '\\' . ($type->getName() === 'self' ? $class->getName() : $type->getName());
198
+        return '\\'.($type->getName() === 'self' ? $class->getName() : $type->getName());
199 199
     }
200 200
 
201 201
     private static function cutDefaultValue(\ReflectionParameter $param): string
202 202
     {
203
-        $string = (string) $param;
203
+        $string = (string)$param;
204 204
 
205 205
         return \trim(\substr($string, \strpos($string, '=') + 1, -1));
206 206
     }
Please login to merge, or discard this patch.
src/Tokenizer/src/Listener/AbstractCachedLoader.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
         protected readonly MemoryInterface $memory,
19 19
         protected readonly ListenerInvoker $invoker,
20 20
         protected readonly bool $readCache = true,
21
-    ) {}
21
+    ){}
22 22
 
23 23
     protected function doLoad(
24 24
         TokenizationListenerInterface $listener,
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $targets = \iterator_to_array($this->parseAttributes($listener));
29 29
 
30 30
         // If there are no targets, then listener can't be cached.
31
-        if ($targets === []) {
31
+        if ($targets === []){
32 32
             return false;
33 33
         }
34 34
 
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
         // We decided to load classes/enums/interfaces for each target separately.
38 38
         // It allows us to cache classes/enums/interfaces for each target separately and if we reuse the
39 39
         // same target in multiple listeners, we will not have to load classes/enums/interfaces for the same target.
40
-        foreach ($targets as $target) {
41
-            $cacheKey = $this->cacheKeyPrefix . $target;
40
+        foreach ($targets as $target){
41
+            $cacheKey = $this->cacheKeyPrefix.$target;
42 42
 
43 43
             $classes = $this->readCache ? $this->memory->loadData($cacheKey) : null;
44
-            if ($classes === null) {
44
+            if ($classes === null){
45 45
                 $this->memory->saveData($cacheKey, $classes = \call_user_func($locator, $target));
46 46
             }
47 47
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@  discard block
 block discarded – undo
18 18
         protected readonly MemoryInterface $memory,
19 19
         protected readonly ListenerInvoker $invoker,
20 20
         protected readonly bool $readCache = true,
21
-    ) {}
21
+    ) {
22
+}
22 23
 
23 24
     protected function doLoad(
24 25
         TokenizationListenerInterface $listener,
@@ -28,7 +29,8 @@  discard block
 block discarded – undo
28 29
         $targets = \iterator_to_array($this->parseAttributes($listener));
29 30
 
30 31
         // If there are no targets, then listener can't be cached.
31
-        if ($targets === []) {
32
+        if ($targets === [])
33
+        {
32 34
             return false;
33 35
         }
34 36
 
@@ -37,11 +39,13 @@  discard block
 block discarded – undo
37 39
         // We decided to load classes/enums/interfaces for each target separately.
38 40
         // It allows us to cache classes/enums/interfaces for each target separately and if we reuse the
39 41
         // same target in multiple listeners, we will not have to load classes/enums/interfaces for the same target.
40
-        foreach ($targets as $target) {
42
+        foreach ($targets as $target)
43
+        {
41 44
             $cacheKey = $this->cacheKeyPrefix . $target;
42 45
 
43 46
             $classes = $this->readCache ? $this->memory->loadData($cacheKey) : null;
44
-            if ($classes === null) {
47
+            if ($classes === null)
48
+            {
45 49
                 $this->memory->saveData($cacheKey, $classes = \call_user_func($locator, $target));
46 50
             }
47 51
 
Please login to merge, or discard this patch.
src/Tokenizer/src/Reflection/ReflectionFile.php 2 patches
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
     public function __construct(
117 117
         private readonly string $filename,
118
-    ) {
118
+    ){
119 119
         $this->tokens = Tokenizer::getTokens($filename);
120 120
         $this->countTokens = \count($this->tokens);
121 121
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function getClasses(): array
146 146
     {
147
-        if (!isset($this->declarations['T_CLASS'])) {
147
+        if (!isset($this->declarations['T_CLASS'])){
148 148
             return [];
149 149
         }
150 150
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function getEnums(): array
158 158
     {
159
-        if (!isset($this->declarations['T_ENUM'])) {
159
+        if (!isset($this->declarations['T_ENUM'])){
160 160
             return [];
161 161
         }
162 162
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function getTraits(): array
170 170
     {
171
-        if (!isset($this->declarations['T_TRAIT'])) {
171
+        if (!isset($this->declarations['T_TRAIT'])){
172 172
             return [];
173 173
         }
174 174
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function getInterfaces(): array
182 182
     {
183
-        if (!isset($this->declarations['T_INTERFACE'])) {
183
+        if (!isset($this->declarations['T_INTERFACE'])){
184 184
             return [];
185 185
         }
186 186
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function getInvocations(): array
213 213
     {
214
-        if (empty($this->invocations)) {
214
+        if (empty($this->invocations)){
215 215
             $this->locateInvocations($this->getTokens());
216 216
         }
217 217
 
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
      */
240 240
     protected function locateDeclarations(): void
241 241
     {
242
-        foreach ($this->getTokens() as $tokenID => $token) {
243
-            if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens)) {
242
+        foreach ($this->getTokens() as $tokenID => $token){
243
+            if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens)){
244 244
                 continue;
245 245
             }
246 246
 
247
-            switch ($token[self::TOKEN_TYPE]) {
247
+            switch ($token[self::TOKEN_TYPE]){
248 248
                 case T_NAMESPACE:
249 249
                     $this->registerNamespace($tokenID);
250 250
                     break;
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
                 case T_TRAIT:
262 262
                 case T_INTERFACE:
263 263
                 case T_ENUM:
264
-                    if ($this->isClassNameConst($tokenID)) {
264
+                    if ($this->isClassNameConst($tokenID)){
265 265
                         // PHP5.5 ClassName::class constant
266 266
                         continue 2;
267 267
                     }
268 268
 
269
-                    if ($this->isAnonymousClass($tokenID)) {
269
+                    if ($this->isAnonymousClass($tokenID)){
270 270
                         // PHP7.0 Anonymous classes new class ('foo', 'bar')
271 271
                         continue 2;
272 272
                     }
273 273
 
274
-                    if (!$this->isCorrectDeclaration($tokenID)) {
274
+                    if (!$this->isCorrectDeclaration($tokenID)){
275 275
                         // PHP8.0 Named parameters ->foo(class: 'bar')
276 276
                         continue 2;
277 277
                     }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         }
289 289
 
290 290
         //Dropping empty namespace
291
-        if (isset($this->namespaces[''])) {
291
+        if (isset($this->namespaces[''])){
292 292
             $this->namespaces['\\'] = $this->namespaces[''];
293 293
             unset($this->namespaces['']);
294 294
         }
@@ -302,14 +302,14 @@  discard block
 block discarded – undo
302 302
         $namespace = '';
303 303
         $localID = $tokenID + 1;
304 304
 
305
-        do {
305
+        do{
306 306
             $token = $this->tokens[$localID++];
307
-            if ($token[self::TOKEN_CODE] === '{') {
307
+            if ($token[self::TOKEN_CODE] === '{'){
308 308
                 break;
309 309
             }
310 310
 
311 311
             $namespace .= $token[self::TOKEN_CODE];
312
-        } while (
312
+        }while (
313 313
             isset($this->tokens[$localID])
314 314
             && $this->tokens[$localID][self::TOKEN_CODE] !== '{'
315 315
             && $this->tokens[$localID][self::TOKEN_CODE] !== ';'
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
         $namespace = \trim($namespace);
320 320
 
321 321
         $uses = [];
322
-        if (isset($this->namespaces[$namespace])) {
322
+        if (isset($this->namespaces[$namespace])){
323 323
             $uses = $this->namespaces[$namespace];
324 324
         }
325 325
 
326
-        if ($this->tokens[$localID][self::TOKEN_CODE] === ';') {
326
+        if ($this->tokens[$localID][self::TOKEN_CODE] === ';'){
327 327
             $endingID = \count($this->tokens) - 1;
328
-        } else {
328
+        }else{
329 329
             $endingID = $this->endingToken($tokenID);
330 330
         }
331 331
 
@@ -345,20 +345,20 @@  discard block
 block discarded – undo
345 345
 
346 346
         $class = '';
347 347
         $localAlias = null;
348
-        for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID) {
349
-            if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS) {
348
+        for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID){
349
+            if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS){
350 350
                 $localAlias = '';
351 351
                 continue;
352 352
             }
353 353
 
354
-            if ($localAlias === null) {
354
+            if ($localAlias === null){
355 355
                 $class .= $this->tokens[$localID][self::TOKEN_CODE];
356
-            } else {
356
+            }else{
357 357
                 $localAlias .= $this->tokens[$localID][self::TOKEN_CODE];
358 358
             }
359 359
         }
360 360
 
361
-        if (empty($localAlias)) {
361
+        if (empty($localAlias)){
362 362
             $names = \explode('\\', $class);
363 363
             $localAlias = \end($names);
364 364
         }
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
      */
372 372
     private function registerFunction(int $tokenID): void
373 373
     {
374
-        foreach ($this->declarations as $declarations) {
375
-            foreach ($declarations as $location) {
376
-                if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]) {
374
+        foreach ($this->declarations as $declarations){
375
+            foreach ($declarations as $location){
376
+                if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]){
377 377
                     //We are inside class, function is method
378 378
                     return;
379 379
                 }
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
         }
382 382
 
383 383
         $localID = $tokenID + 1;
384
-        while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) {
384
+        while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING){
385 385
             //Fetching function name
386 386
             ++$localID;
387 387
         }
388 388
 
389 389
         $name = $this->tokens[$localID][self::TOKEN_CODE];
390
-        if (!empty($namespace = $this->activeNamespace($tokenID))) {
391
-            $name = $namespace . self::NS_SEPARATOR . $name;
390
+        if (!empty($namespace = $this->activeNamespace($tokenID))){
391
+            $name = $namespace.self::NS_SEPARATOR.$name;
392 392
         }
393 393
 
394 394
         $this->functions[$name] = [
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
     private function registerDeclaration(int $tokenID, int $tokenType): void
405 405
     {
406 406
         $localID = $tokenID + 1;
407
-        while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) {
407
+        while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING){
408 408
             ++$localID;
409 409
         }
410 410
 
411 411
         $name = $this->tokens[$localID][self::TOKEN_CODE];
412
-        if (!empty($namespace = $this->activeNamespace($tokenID))) {
413
-            $name = $namespace . self::NS_SEPARATOR . $name;
412
+        if (!empty($namespace = $this->activeNamespace($tokenID))){
413
+            $name = $namespace.self::NS_SEPARATOR.$name;
414 414
         }
415 415
 
416 416
         $this->declarations[\token_name($tokenType)][$name] = [
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
     /**
433 433
      * Check if token ID represents anonymous class creation, e.g. `new class ('foo', 'bar')`.
434 434
      */
435
-    private function isAnonymousClass(int|string $tokenID): bool
435
+    private function isAnonymousClass(int | string $tokenID): bool
436 436
     {
437 437
         return $this->tokens[$tokenID][self::TOKEN_TYPE] === T_CLASS
438 438
             && isset($this->tokens[$tokenID - 2])
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     /**
443 443
      * Check if token ID represents named parameter with name `class`, e.g. `foo(class: SomeClass::name)`.
444 444
      */
445
-    private function isCorrectDeclaration(int|string $tokenID): bool
445
+    private function isCorrectDeclaration(int | string $tokenID): bool
446 446
     {
447 447
         return \in_array($this->tokens[$tokenID][self::TOKEN_TYPE], [T_CLASS, T_TRAIT, T_INTERFACE, T_ENUM], true)
448 448
             && isset($this->tokens[$tokenID + 2])
@@ -474,24 +474,24 @@  discard block
 block discarded – undo
474 474
 
475 475
         //Tokens used to re-enable token detection
476 476
         $stopTokens = [T_STRING, T_WHITESPACE, T_DOUBLE_COLON, T_OBJECT_OPERATOR, T_NS_SEPARATOR];
477
-        foreach ($tokens as $tokenID => $token) {
477
+        foreach ($tokens as $tokenID => $token){
478 478
             $tokenType = $token[self::TOKEN_TYPE];
479 479
 
480 480
             //We are not indexing function declarations or functions called from $objects.
481
-            if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])) {
481
+            if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])){
482 482
                 if (
483 483
                     empty($argumentsTID)
484 484
                     && (
485 485
                         empty($invocationTID)
486 486
                         || $this->getSource($invocationTID, $tokenID - 1) !== '$this'
487 487
                     )
488
-                ) {
488
+                ){
489 489
                     //Not a call, function declaration, or object method
490 490
                     $ignore = true;
491 491
                     continue;
492 492
                 }
493
-            } elseif ($ignore) {
494
-                if (!\in_array($tokenType, $stopTokens)) {
493
+            } elseif ($ignore){
494
+                if (!\in_array($tokenType, $stopTokens)){
495 495
                     //Returning to search
496 496
                     $ignore = false;
497 497
                 }
@@ -499,13 +499,13 @@  discard block
 block discarded – undo
499 499
             }
500 500
 
501 501
             //We are inside function, and there is "(", indexing arguments.
502
-            if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '[')) {
503
-                if (empty($argumentsTID)) {
502
+            if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '[')){
503
+                if (empty($argumentsTID)){
504 504
                     $argumentsTID = $tokenID;
505 505
                 }
506 506
 
507 507
                 ++$level;
508
-                if ($level != 1) {
508
+                if ($level != 1){
509 509
                     //Not arguments beginning, but arguments part
510 510
                     $arguments[$tokenID] = $token;
511 511
                 }
@@ -514,16 +514,16 @@  discard block
 block discarded – undo
514 514
             }
515 515
 
516 516
             //We are inside function arguments and ")" met.
517
-            if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']')) {
517
+            if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']')){
518 518
                 --$level;
519
-                if ($level == -1) {
519
+                if ($level == -1){
520 520
                     $invocationTID = false;
521 521
                     $level = 0;
522 522
                     continue;
523 523
                 }
524 524
 
525 525
                 //Function fully indexed, we can process it now.
526
-                if ($level == 0) {
526
+                if ($level == 0){
527 527
                     $this->registerInvocation(
528 528
                         $invocationTID,
529 529
                         $argumentsTID,
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
                     //Closing search
536 536
                     $arguments = [];
537 537
                     $argumentsTID = $invocationTID = false;
538
-                } else {
538
+                }else{
539 539
                     //Not arguments beginning, but arguments part
540 540
                     $arguments[$tokenID] = $token;
541 541
                 }
@@ -544,13 +544,13 @@  discard block
 block discarded – undo
544 544
             }
545 545
 
546 546
             //Still inside arguments.
547
-            if (!empty($invocationTID) && !empty($level)) {
547
+            if (!empty($invocationTID) && !empty($level)){
548 548
                 $arguments[$tokenID] = $token;
549 549
                 continue;
550 550
             }
551 551
 
552 552
             //Nothing valuable to remember, will be parsed later.
553
-            if (!empty($invocationTID) && \in_array($tokenType, $stopTokens)) {
553
+            if (!empty($invocationTID) && \in_array($tokenType, $stopTokens)){
554 554
                 continue;
555 555
             }
556 556
 
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
                 || $tokenType == T_STATIC
561 561
                 || $tokenType == T_NS_SEPARATOR
562 562
                 || ($tokenType == T_VARIABLE && $token[self::TOKEN_CODE] === '$this')
563
-            ) {
563
+            ){
564 564
                 $invocationTID = $tokenID;
565 565
                 $level = 0;
566 566
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 
590 590
         [$class, $operator, $name] = $this->fetchContext($invocationID, $argumentsID);
591 591
 
592
-        if (!empty($operator) && empty($class)) {
592
+        if (!empty($operator) && empty($class)){
593 593
             //Non detectable
594 594
             return;
595 595
         }
@@ -615,17 +615,17 @@  discard block
 block discarded – undo
615 615
         $name = \trim($this->getSource($invocationTID, $argumentsTID), '( ');
616 616
 
617 617
         //Let's try to fetch all information we need
618
-        if (\str_contains($name, '->')) {
618
+        if (\str_contains($name, '->')){
619 619
             $operator = '->';
620
-        } elseif (\str_contains($name, '::')) {
620
+        } elseif (\str_contains($name, '::')){
621 621
             $operator = '::';
622 622
         }
623 623
 
624
-        if (!empty($operator)) {
624
+        if (!empty($operator)){
625 625
             [$class, $name] = \explode($operator, $name);
626 626
 
627 627
             //We now have to clarify class name
628
-            if (\in_array($class, ['self', 'static', '$this'])) {
628
+            if (\in_array($class, ['self', 'static', '$this'])){
629 629
                 $class = $this->activeDeclaration($invocationTID);
630 630
             }
631 631
         }
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
      */
639 639
     private function activeDeclaration(int $tokenID): string
640 640
     {
641
-        foreach ($this->declarations as $declarations) {
642
-            foreach ($declarations as $name => $position) {
643
-                if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
641
+        foreach ($this->declarations as $declarations){
642
+            foreach ($declarations as $name => $position){
643
+                if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]){
644 644
                     return $name;
645 645
                 }
646 646
             }
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
      */
656 656
     private function activeNamespace(int $tokenID): string
657 657
     {
658
-        foreach ($this->namespaces as $namespace => $position) {
659
-            if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
658
+        foreach ($this->namespaces as $namespace => $position){
659
+            if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]){
660 660
                 return $namespace;
661 661
             }
662 662
         }
@@ -677,18 +677,18 @@  discard block
 block discarded – undo
677 677
     private function endingToken(int $tokenID): int
678 678
     {
679 679
         $level = null;
680
-        for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) {
680
+        for ($localID = $tokenID; $localID < $this->countTokens; ++$localID){
681 681
             $token = $this->tokens[$localID];
682
-            if ($token[self::TOKEN_CODE] === '{') {
682
+            if ($token[self::TOKEN_CODE] === '{'){
683 683
                 ++$level;
684 684
                 continue;
685 685
             }
686 686
 
687
-            if ($token[self::TOKEN_CODE] === '}') {
687
+            if ($token[self::TOKEN_CODE] === '}'){
688 688
                 --$level;
689 689
             }
690 690
 
691
-            if ($level === 0) {
691
+            if ($level === 0){
692 692
                 break;
693 693
             }
694 694
         }
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
      */
702 702
     private function lineNumber(int $tokenID): int
703 703
     {
704
-        while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) {
704
+        while (empty($this->tokens[$tokenID][self::TOKEN_LINE])){
705 705
             --$tokenID;
706 706
         }
707 707
 
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
     private function getSource(int $startID, int $endID): string
715 715
     {
716 716
         $result = '';
717
-        for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) {
717
+        for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID){
718 718
             //Collecting function usage src
719 719
             $result .= $this->tokens[$tokenID][self::TOKEN_CODE];
720 720
         }
Please login to merge, or discard this patch.
Braces   +121 added lines, -58 removed lines patch added patch discarded remove patch
@@ -144,7 +144,8 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function getClasses(): array
146 146
     {
147
-        if (!isset($this->declarations['T_CLASS'])) {
147
+        if (!isset($this->declarations['T_CLASS']))
148
+        {
148 149
             return [];
149 150
         }
150 151
 
@@ -156,7 +157,8 @@  discard block
 block discarded – undo
156 157
      */
157 158
     public function getEnums(): array
158 159
     {
159
-        if (!isset($this->declarations['T_ENUM'])) {
160
+        if (!isset($this->declarations['T_ENUM']))
161
+        {
160 162
             return [];
161 163
         }
162 164
 
@@ -168,7 +170,8 @@  discard block
 block discarded – undo
168 170
      */
169 171
     public function getTraits(): array
170 172
     {
171
-        if (!isset($this->declarations['T_TRAIT'])) {
173
+        if (!isset($this->declarations['T_TRAIT']))
174
+        {
172 175
             return [];
173 176
         }
174 177
 
@@ -180,7 +183,8 @@  discard block
 block discarded – undo
180 183
      */
181 184
     public function getInterfaces(): array
182 185
     {
183
-        if (!isset($this->declarations['T_INTERFACE'])) {
186
+        if (!isset($this->declarations['T_INTERFACE']))
187
+        {
184 188
             return [];
185 189
         }
186 190
 
@@ -211,7 +215,8 @@  discard block
 block discarded – undo
211 215
      */
212 216
     public function getInvocations(): array
213 217
     {
214
-        if (empty($this->invocations)) {
218
+        if (empty($this->invocations))
219
+        {
215 220
             $this->locateInvocations($this->getTokens());
216 221
         }
217 222
 
@@ -239,12 +244,15 @@  discard block
 block discarded – undo
239 244
      */
240 245
     protected function locateDeclarations(): void
241 246
     {
242
-        foreach ($this->getTokens() as $tokenID => $token) {
243
-            if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens)) {
247
+        foreach ($this->getTokens() as $tokenID => $token)
248
+        {
249
+            if (!\in_array($token[self::TOKEN_TYPE], self::$processTokens))
250
+            {
244 251
                 continue;
245 252
             }
246 253
 
247
-            switch ($token[self::TOKEN_TYPE]) {
254
+            switch ($token[self::TOKEN_TYPE])
255
+            {
248 256
                 case T_NAMESPACE:
249 257
                     $this->registerNamespace($tokenID);
250 258
                     break;
@@ -261,17 +269,20 @@  discard block
 block discarded – undo
261 269
                 case T_TRAIT:
262 270
                 case T_INTERFACE:
263 271
                 case T_ENUM:
264
-                    if ($this->isClassNameConst($tokenID)) {
272
+                    if ($this->isClassNameConst($tokenID))
273
+                    {
265 274
                         // PHP5.5 ClassName::class constant
266 275
                         continue 2;
267 276
                     }
268 277
 
269
-                    if ($this->isAnonymousClass($tokenID)) {
278
+                    if ($this->isAnonymousClass($tokenID))
279
+                    {
270 280
                         // PHP7.0 Anonymous classes new class ('foo', 'bar')
271 281
                         continue 2;
272 282
                     }
273 283
 
274
-                    if (!$this->isCorrectDeclaration($tokenID)) {
284
+                    if (!$this->isCorrectDeclaration($tokenID))
285
+                    {
275 286
                         // PHP8.0 Named parameters ->foo(class: 'bar')
276 287
                         continue 2;
277 288
                     }
@@ -288,7 +299,8 @@  discard block
 block discarded – undo
288 299
         }
289 300
 
290 301
         //Dropping empty namespace
291
-        if (isset($this->namespaces[''])) {
302
+        if (isset($this->namespaces['']))
303
+        {
292 304
             $this->namespaces['\\'] = $this->namespaces[''];
293 305
             unset($this->namespaces['']);
294 306
         }
@@ -302,9 +314,11 @@  discard block
 block discarded – undo
302 314
         $namespace = '';
303 315
         $localID = $tokenID + 1;
304 316
 
305
-        do {
317
+        do
318
+        {
306 319
             $token = $this->tokens[$localID++];
307
-            if ($token[self::TOKEN_CODE] === '{') {
320
+            if ($token[self::TOKEN_CODE] === '{')
321
+            {
308 322
                 break;
309 323
             }
310 324
 
@@ -319,13 +333,17 @@  discard block
 block discarded – undo
319 333
         $namespace = \trim($namespace);
320 334
 
321 335
         $uses = [];
322
-        if (isset($this->namespaces[$namespace])) {
336
+        if (isset($this->namespaces[$namespace]))
337
+        {
323 338
             $uses = $this->namespaces[$namespace];
324 339
         }
325 340
 
326
-        if ($this->tokens[$localID][self::TOKEN_CODE] === ';') {
341
+        if ($this->tokens[$localID][self::TOKEN_CODE] === ';')
342
+        {
327 343
             $endingID = \count($this->tokens) - 1;
328
-        } else {
344
+        }
345
+        else
346
+        {
329 347
             $endingID = $this->endingToken($tokenID);
330 348
         }
331 349
 
@@ -345,20 +363,26 @@  discard block
 block discarded – undo
345 363
 
346 364
         $class = '';
347 365
         $localAlias = null;
348
-        for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID) {
349
-            if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS) {
366
+        for ($localID = $tokenID + 1; $this->tokens[$localID][self::TOKEN_CODE] !== ';'; ++$localID)
367
+        {
368
+            if ($this->tokens[$localID][self::TOKEN_TYPE] == T_AS)
369
+            {
350 370
                 $localAlias = '';
351 371
                 continue;
352 372
             }
353 373
 
354
-            if ($localAlias === null) {
374
+            if ($localAlias === null)
375
+            {
355 376
                 $class .= $this->tokens[$localID][self::TOKEN_CODE];
356
-            } else {
377
+            }
378
+            else
379
+            {
357 380
                 $localAlias .= $this->tokens[$localID][self::TOKEN_CODE];
358 381
             }
359 382
         }
360 383
 
361
-        if (empty($localAlias)) {
384
+        if (empty($localAlias))
385
+        {
362 386
             $names = \explode('\\', $class);
363 387
             $localAlias = \end($names);
364 388
         }
@@ -371,9 +395,12 @@  discard block
 block discarded – undo
371 395
      */
372 396
     private function registerFunction(int $tokenID): void
373 397
     {
374
-        foreach ($this->declarations as $declarations) {
375
-            foreach ($declarations as $location) {
376
-                if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN]) {
398
+        foreach ($this->declarations as $declarations)
399
+        {
400
+            foreach ($declarations as $location)
401
+            {
402
+                if ($tokenID >= $location[self::O_TOKEN] && $tokenID <= $location[self::C_TOKEN])
403
+                {
377 404
                     //We are inside class, function is method
378 405
                     return;
379 406
                 }
@@ -381,13 +408,15 @@  discard block
 block discarded – undo
381 408
         }
382 409
 
383 410
         $localID = $tokenID + 1;
384
-        while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) {
411
+        while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING)
412
+        {
385 413
             //Fetching function name
386 414
             ++$localID;
387 415
         }
388 416
 
389 417
         $name = $this->tokens[$localID][self::TOKEN_CODE];
390
-        if (!empty($namespace = $this->activeNamespace($tokenID))) {
418
+        if (!empty($namespace = $this->activeNamespace($tokenID)))
419
+        {
391 420
             $name = $namespace . self::NS_SEPARATOR . $name;
392 421
         }
393 422
 
@@ -404,12 +433,14 @@  discard block
 block discarded – undo
404 433
     private function registerDeclaration(int $tokenID, int $tokenType): void
405 434
     {
406 435
         $localID = $tokenID + 1;
407
-        while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING) {
436
+        while ($this->tokens[$localID][self::TOKEN_TYPE] !== T_STRING)
437
+        {
408 438
             ++$localID;
409 439
         }
410 440
 
411 441
         $name = $this->tokens[$localID][self::TOKEN_CODE];
412
-        if (!empty($namespace = $this->activeNamespace($tokenID))) {
442
+        if (!empty($namespace = $this->activeNamespace($tokenID)))
443
+        {
413 444
             $name = $namespace . self::NS_SEPARATOR . $name;
414 445
         }
415 446
 
@@ -474,11 +505,13 @@  discard block
 block discarded – undo
474 505
 
475 506
         //Tokens used to re-enable token detection
476 507
         $stopTokens = [T_STRING, T_WHITESPACE, T_DOUBLE_COLON, T_OBJECT_OPERATOR, T_NS_SEPARATOR];
477
-        foreach ($tokens as $tokenID => $token) {
508
+        foreach ($tokens as $tokenID => $token)
509
+        {
478 510
             $tokenType = $token[self::TOKEN_TYPE];
479 511
 
480 512
             //We are not indexing function declarations or functions called from $objects.
481
-            if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW])) {
513
+            if (\in_array($tokenType, [T_FUNCTION, T_OBJECT_OPERATOR, T_NEW]))
514
+            {
482 515
                 if (
483 516
                     empty($argumentsTID)
484 517
                     && (
@@ -490,8 +523,11 @@  discard block
 block discarded – undo
490 523
                     $ignore = true;
491 524
                     continue;
492 525
                 }
493
-            } elseif ($ignore) {
494
-                if (!\in_array($tokenType, $stopTokens)) {
526
+            }
527
+            elseif ($ignore)
528
+            {
529
+                if (!\in_array($tokenType, $stopTokens))
530
+                {
495 531
                     //Returning to search
496 532
                     $ignore = false;
497 533
                 }
@@ -499,13 +535,16 @@  discard block
 block discarded – undo
499 535
             }
500 536
 
501 537
             //We are inside function, and there is "(", indexing arguments.
502
-            if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '[')) {
503
-                if (empty($argumentsTID)) {
538
+            if (!empty($invocationTID) && ($tokenType === '(' || $tokenType === '['))
539
+            {
540
+                if (empty($argumentsTID))
541
+                {
504 542
                     $argumentsTID = $tokenID;
505 543
                 }
506 544
 
507 545
                 ++$level;
508
-                if ($level != 1) {
546
+                if ($level != 1)
547
+                {
509 548
                     //Not arguments beginning, but arguments part
510 549
                     $arguments[$tokenID] = $token;
511 550
                 }
@@ -514,16 +553,19 @@  discard block
 block discarded – undo
514 553
             }
515 554
 
516 555
             //We are inside function arguments and ")" met.
517
-            if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']')) {
556
+            if (!empty($invocationTID) && ($tokenType === ')' || $tokenType === ']'))
557
+            {
518 558
                 --$level;
519
-                if ($level == -1) {
559
+                if ($level == -1)
560
+                {
520 561
                     $invocationTID = false;
521 562
                     $level = 0;
522 563
                     continue;
523 564
                 }
524 565
 
525 566
                 //Function fully indexed, we can process it now.
526
-                if ($level == 0) {
567
+                if ($level == 0)
568
+                {
527 569
                     $this->registerInvocation(
528 570
                         $invocationTID,
529 571
                         $argumentsTID,
@@ -535,7 +577,9 @@  discard block
 block discarded – undo
535 577
                     //Closing search
536 578
                     $arguments = [];
537 579
                     $argumentsTID = $invocationTID = false;
538
-                } else {
580
+                }
581
+                else
582
+                {
539 583
                     //Not arguments beginning, but arguments part
540 584
                     $arguments[$tokenID] = $token;
541 585
                 }
@@ -544,13 +588,15 @@  discard block
 block discarded – undo
544 588
             }
545 589
 
546 590
             //Still inside arguments.
547
-            if (!empty($invocationTID) && !empty($level)) {
591
+            if (!empty($invocationTID) && !empty($level))
592
+            {
548 593
                 $arguments[$tokenID] = $token;
549 594
                 continue;
550 595
             }
551 596
 
552 597
             //Nothing valuable to remember, will be parsed later.
553
-            if (!empty($invocationTID) && \in_array($tokenType, $stopTokens)) {
598
+            if (!empty($invocationTID) && \in_array($tokenType, $stopTokens))
599
+            {
554 600
                 continue;
555 601
             }
556 602
 
@@ -589,7 +635,8 @@  discard block
 block discarded – undo
589 635
 
590 636
         [$class, $operator, $name] = $this->fetchContext($invocationID, $argumentsID);
591 637
 
592
-        if (!empty($operator) && empty($class)) {
638
+        if (!empty($operator) && empty($class))
639
+        {
593 640
             //Non detectable
594 641
             return;
595 642
         }
@@ -615,17 +662,22 @@  discard block
 block discarded – undo
615 662
         $name = \trim($this->getSource($invocationTID, $argumentsTID), '( ');
616 663
 
617 664
         //Let's try to fetch all information we need
618
-        if (\str_contains($name, '->')) {
665
+        if (\str_contains($name, '->'))
666
+        {
619 667
             $operator = '->';
620
-        } elseif (\str_contains($name, '::')) {
668
+        }
669
+        elseif (\str_contains($name, '::'))
670
+        {
621 671
             $operator = '::';
622 672
         }
623 673
 
624
-        if (!empty($operator)) {
674
+        if (!empty($operator))
675
+        {
625 676
             [$class, $name] = \explode($operator, $name);
626 677
 
627 678
             //We now have to clarify class name
628
-            if (\in_array($class, ['self', 'static', '$this'])) {
679
+            if (\in_array($class, ['self', 'static', '$this']))
680
+            {
629 681
                 $class = $this->activeDeclaration($invocationTID);
630 682
             }
631 683
         }
@@ -638,9 +690,12 @@  discard block
 block discarded – undo
638 690
      */
639 691
     private function activeDeclaration(int $tokenID): string
640 692
     {
641
-        foreach ($this->declarations as $declarations) {
642
-            foreach ($declarations as $name => $position) {
643
-                if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
693
+        foreach ($this->declarations as $declarations)
694
+        {
695
+            foreach ($declarations as $name => $position)
696
+            {
697
+                if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN])
698
+                {
644 699
                     return $name;
645 700
                 }
646 701
             }
@@ -655,8 +710,10 @@  discard block
 block discarded – undo
655 710
      */
656 711
     private function activeNamespace(int $tokenID): string
657 712
     {
658
-        foreach ($this->namespaces as $namespace => $position) {
659
-            if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN]) {
713
+        foreach ($this->namespaces as $namespace => $position)
714
+        {
715
+            if ($tokenID >= $position[self::O_TOKEN] && $tokenID <= $position[self::C_TOKEN])
716
+            {
660 717
                 return $namespace;
661 718
             }
662 719
         }
@@ -677,18 +734,22 @@  discard block
 block discarded – undo
677 734
     private function endingToken(int $tokenID): int
678 735
     {
679 736
         $level = null;
680
-        for ($localID = $tokenID; $localID < $this->countTokens; ++$localID) {
737
+        for ($localID = $tokenID; $localID < $this->countTokens; ++$localID)
738
+        {
681 739
             $token = $this->tokens[$localID];
682
-            if ($token[self::TOKEN_CODE] === '{') {
740
+            if ($token[self::TOKEN_CODE] === '{')
741
+            {
683 742
                 ++$level;
684 743
                 continue;
685 744
             }
686 745
 
687
-            if ($token[self::TOKEN_CODE] === '}') {
746
+            if ($token[self::TOKEN_CODE] === '}')
747
+            {
688 748
                 --$level;
689 749
             }
690 750
 
691
-            if ($level === 0) {
751
+            if ($level === 0)
752
+            {
692 753
                 break;
693 754
             }
694 755
         }
@@ -701,7 +762,8 @@  discard block
 block discarded – undo
701 762
      */
702 763
     private function lineNumber(int $tokenID): int
703 764
     {
704
-        while (empty($this->tokens[$tokenID][self::TOKEN_LINE])) {
765
+        while (empty($this->tokens[$tokenID][self::TOKEN_LINE]))
766
+        {
705 767
             --$tokenID;
706 768
         }
707 769
 
@@ -714,7 +776,8 @@  discard block
 block discarded – undo
714 776
     private function getSource(int $startID, int $endID): string
715 777
     {
716 778
         $result = '';
717
-        for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID) {
779
+        for ($tokenID = $startID; $tokenID <= $endID; ++$tokenID)
780
+        {
718 781
             //Collecting function usage src
719 782
             $result .= $this->tokens[$tokenID][self::TOKEN_CODE];
720 783
         }
Please login to merge, or discard this patch.
src/AuthHttp/tests/HeaderTransportTest.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 
27 27
         $http->setHandler(
28 28
             static function (ServerRequestInterface $request): void {
29
-                if ($request->getAttribute('authContext')->getToken() === null) {
29
+                if ($request->getAttribute('authContext')->getToken() === null){
30 30
                     echo 'no token';
31
-                } else {
31
+                }else{
32 32
                     echo $request->getAttribute('authContext')->getToken()->getID();
33 33
                     echo ':';
34 34
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         );
42 42
 
43 43
         self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type'));
44
-        self::assertSame('good-token:{"id":"good-token"}', (string) $response->getBody());
44
+        self::assertSame('good-token:{"id":"good-token"}', (string)$response->getBody());
45 45
     }
46 46
 
47 47
     public function testHeaderTokenWithCustomValueFormat(): void
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
         $http->setHandler(
52 52
             static function (ServerRequestInterface $request): void {
53
-                if ($request->getAttribute('authContext')->getToken() === null) {
53
+                if ($request->getAttribute('authContext')->getToken() === null){
54 54
                     echo 'no token';
55
-                } else {
55
+                }else{
56 56
                     echo $request->getAttribute('authContext')->getToken()->getID();
57 57
                     echo ':';
58 58
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         );
66 66
 
67 67
         self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type'));
68
-        self::assertSame('good-token:{"id":"good-token"}', (string) $response->getBody());
68
+        self::assertSame('good-token:{"id":"good-token"}', (string)$response->getBody());
69 69
     }
70 70
 
71 71
     public function testBadHeaderToken(): void
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 
75 75
         $http->setHandler(
76 76
             static function (ServerRequestInterface $request): void {
77
-                if ($request->getAttribute('authContext')->getToken() === null) {
77
+                if ($request->getAttribute('authContext')->getToken() === null){
78 78
                     echo 'no token';
79
-                } else {
79
+                }else{
80 80
                     echo $request->getAttribute('authContext')->getToken()->getID();
81 81
                     echo ':';
82 82
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         );
90 90
 
91 91
         self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type'));
92
-        self::assertSame('no token', (string) $response->getBody());
92
+        self::assertSame('no token', (string)$response->getBody());
93 93
     }
94 94
 
95 95
     public function testDeleteToken(): void
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         );
108 108
 
109 109
         self::assertEmpty($response->getHeader('X-Auth-Token'));
110
-        self::assertSame('closed', (string) $response->getBody());
110
+        self::assertSame('closed', (string)$response->getBody());
111 111
     }
112 112
 
113 113
     public function testCommitToken(): void
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,9 +26,12 @@  discard block
 block discarded – undo
26 26
 
27 27
         $http->setHandler(
28 28
             static function (ServerRequestInterface $request): void {
29
-                if ($request->getAttribute('authContext')->getToken() === null) {
29
+                if ($request->getAttribute('authContext')->getToken() === null)
30
+                {
30 31
                     echo 'no token';
31
-                } else {
32
+                }
33
+                else
34
+                {
32 35
                     echo $request->getAttribute('authContext')->getToken()->getID();
33 36
                     echo ':';
34 37
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -50,9 +53,12 @@  discard block
 block discarded – undo
50 53
 
51 54
         $http->setHandler(
52 55
             static function (ServerRequestInterface $request): void {
53
-                if ($request->getAttribute('authContext')->getToken() === null) {
56
+                if ($request->getAttribute('authContext')->getToken() === null)
57
+                {
54 58
                     echo 'no token';
55
-                } else {
59
+                }
60
+                else
61
+                {
56 62
                     echo $request->getAttribute('authContext')->getToken()->getID();
57 63
                     echo ':';
58 64
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -74,9 +80,12 @@  discard block
 block discarded – undo
74 80
 
75 81
         $http->setHandler(
76 82
             static function (ServerRequestInterface $request): void {
77
-                if ($request->getAttribute('authContext')->getToken() === null) {
83
+                if ($request->getAttribute('authContext')->getToken() === null)
84
+                {
78 85
                     echo 'no token';
79
-                } else {
86
+                }
87
+                else
88
+                {
80 89
                     echo $request->getAttribute('authContext')->getToken()->getID();
81 90
                     echo ':';
82 91
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
Please login to merge, or discard this patch.
src/AuthHttp/tests/CookieTransportTest.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
         $http->setHandler(
30 30
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
31
-                if ($request->getAttribute('authContext')->getToken() === null) {
31
+                if ($request->getAttribute('authContext')->getToken() === null){
32 32
                     echo 'no token';
33
-                } else {
33
+                }else{
34 34
                     echo $request->getAttribute('authContext')->getToken()->getID();
35 35
                     echo ':';
36 36
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         );
44 44
 
45 45
         self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type'));
46
-        self::assertSame('good-token:{"id":"good-token"}', (string) $response->getBody());
46
+        self::assertSame('good-token:{"id":"good-token"}', (string)$response->getBody());
47 47
     }
48 48
 
49 49
     public function testBadCookieToken(): void
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
         $http->setHandler(
54 54
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
55
-                if ($request->getAttribute('authContext')->getToken() === null) {
55
+                if ($request->getAttribute('authContext')->getToken() === null){
56 56
                     echo 'no token';
57
-                } else {
57
+                }else{
58 58
                     echo $request->getAttribute('authContext')->getToken()->getID();
59 59
                     echo ':';
60 60
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         );
68 68
 
69 69
         self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type'));
70
-        self::assertSame('no token', (string) $response->getBody());
70
+        self::assertSame('no token', (string)$response->getBody());
71 71
     }
72 72
 
73 73
     public function testDeleteToken(): void
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         );
88 88
 
89 89
         self::assertSame(['auth-token=; Path=/; HttpOnly'], $response->getHeader('Set-Cookie'));
90
-        self::assertSame('closed', (string) $response->getBody());
90
+        self::assertSame('closed', (string)$response->getBody());
91 91
     }
92 92
 
93 93
     public function testCommitToken(): void
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         );
152 152
 
153 153
         self::assertSame(
154
-            'Expires=' . \gmdate(DATE_COOKIE, \time() + 3600),
154
+            'Expires='.\gmdate(DATE_COOKIE, \time() + 3600),
155 155
             $cookie[1],
156 156
         );
157 157
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,9 +28,12 @@  discard block
 block discarded – undo
28 28
 
29 29
         $http->setHandler(
30 30
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
31
-                if ($request->getAttribute('authContext')->getToken() === null) {
31
+                if ($request->getAttribute('authContext')->getToken() === null)
32
+                {
32 33
                     echo 'no token';
33
-                } else {
34
+                }
35
+                else
36
+                {
34 37
                     echo $request->getAttribute('authContext')->getToken()->getID();
35 38
                     echo ':';
36 39
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
@@ -52,9 +55,12 @@  discard block
 block discarded – undo
52 55
 
53 56
         $http->setHandler(
54 57
             static function (ServerRequestInterface $request, ResponseInterface $response): void {
55
-                if ($request->getAttribute('authContext')->getToken() === null) {
58
+                if ($request->getAttribute('authContext')->getToken() === null)
59
+                {
56 60
                     echo 'no token';
57
-                } else {
61
+                }
62
+                else
63
+                {
58 64
                     echo $request->getAttribute('authContext')->getToken()->getID();
59 65
                     echo ':';
60 66
                     echo \json_encode($request->getAttribute('authContext')->getToken()->getPayload());
Please login to merge, or discard this patch.
src/AuthHttp/src/Transport/HeaderTransport.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
     public function __construct(
17 17
         private readonly string $header = 'X-Auth-Token',
18 18
         private readonly string $valueFormat = '%s',
19
-    ) {}
19
+    ){}
20 20
 
21 21
     public function fetchToken(Request $request): ?string
22 22
     {
23
-        if ($request->hasHeader($this->header)) {
23
+        if ($request->hasHeader($this->header)){
24 24
             return $this->extractToken($request);
25 25
         }
26 26
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         string $tokenID,
34 34
         ?\DateTimeInterface $expiresAt = null,
35 35
     ): Response {
36
-        if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) {
36
+        if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID){
37 37
             return $response;
38 38
         }
39 39
 
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $headerLine = $request->getHeaderLine($this->header);
51 51
 
52
-        if ($this->valueFormat !== '%s') {
52
+        if ($this->valueFormat !== '%s'){
53 53
             [$token] = \sscanf($headerLine, $this->valueFormat);
54 54
 
55
-            return $token !== null ? (string) $token : null;
55
+            return $token !== null ? (string)$token : null;
56 56
         }
57 57
 
58 58
         return $headerLine;
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,11 +16,13 @@  discard block
 block discarded – undo
16 16
     public function __construct(
17 17
         private readonly string $header = 'X-Auth-Token',
18 18
         private readonly string $valueFormat = '%s',
19
-    ) {}
19
+    ) {
20
+}
20 21
 
21 22
     public function fetchToken(Request $request): ?string
22 23
     {
23
-        if ($request->hasHeader($this->header)) {
24
+        if ($request->hasHeader($this->header))
25
+        {
24 26
             return $this->extractToken($request);
25 27
         }
26 28
 
@@ -33,7 +35,8 @@  discard block
 block discarded – undo
33 35
         string $tokenID,
34 36
         ?\DateTimeInterface $expiresAt = null,
35 37
     ): Response {
36
-        if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) {
38
+        if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID)
39
+        {
37 40
             return $response;
38 41
         }
39 42
 
@@ -49,7 +52,8 @@  discard block
 block discarded – undo
49 52
     {
50 53
         $headerLine = $request->getHeaderLine($this->header);
51 54
 
52
-        if ($this->valueFormat !== '%s') {
55
+        if ($this->valueFormat !== '%s')
56
+        {
53 57
             [$token] = \sscanf($headerLine, $this->valueFormat);
54 58
 
55 59
             return $token !== null ? (string) $token : null;
Please login to merge, or discard this patch.
src/Streams/tests/StreamsTest.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 class StreamsTest extends TestCase
14 14
 {
15
-    private const FIXTURE_DIRECTORY = __DIR__ . '/fixtures';
15
+    private const FIXTURE_DIRECTORY = __DIR__.'/fixtures';
16 16
 
17 17
     public function testGetUri(): void
18 18
     {
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         self::assertSame(\strlen('sample text'), \filesize($filename));
26 26
         self::assertSame(\md5('sample text'), \md5_file($filename));
27 27
 
28
-        $newFilename = self::FIXTURE_DIRECTORY . '/test.txt';
28
+        $newFilename = self::FIXTURE_DIRECTORY.'/test.txt';
29 29
         \copy($filename, $newFilename);
30 30
 
31 31
         self::assertFileExists($newFilename);
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function testException(): void
68 68
     {
69
-        try {
69
+        try{
70 70
             \fopen('spiral://non-exists', 'rb');
71
-        } catch (\Throwable $e) {
71
+        }catch (\Throwable $e){
72 72
             self::assertStringContainsString('failed to open stream', $e->getMessage());
73 73
         }
74 74
 
75
-        try {
75
+        try{
76 76
             \filemtime('spiral://non-exists');
77
-        } catch (\Throwable $e) {
77
+        }catch (\Throwable $e){
78 78
             self::assertStringContainsString('stat failed', $e->getMessage());
79 79
         }
80 80
     }
@@ -84,15 +84,15 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function testExceptionPHP8(): void
86 86
     {
87
-        try {
87
+        try{
88 88
             \fopen('spiral://non-exists', 'rb');
89
-        } catch (\Throwable $e) {
89
+        }catch (\Throwable $e){
90 90
             self::assertStringContainsString('Failed to open stream', $e->getMessage());
91 91
         }
92 92
 
93
-        try {
93
+        try{
94 94
             \filemtime('spiral://non-exists');
95
-        } catch (\Throwable $e) {
95
+        }catch (\Throwable $e){
96 96
             self::assertStringContainsString('stat failed', $e->getMessage());
97 97
         }
98 98
     }
Please login to merge, or discard this patch.
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -66,15 +66,21 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function testException(): void
68 68
     {
69
-        try {
69
+        try
70
+        {
70 71
             \fopen('spiral://non-exists', 'rb');
71
-        } catch (\Throwable $e) {
72
+        }
73
+        catch (\Throwable $e)
74
+        {
72 75
             self::assertStringContainsString('failed to open stream', $e->getMessage());
73 76
         }
74 77
 
75
-        try {
78
+        try
79
+        {
76 80
             \filemtime('spiral://non-exists');
77
-        } catch (\Throwable $e) {
81
+        }
82
+        catch (\Throwable $e)
83
+        {
78 84
             self::assertStringContainsString('stat failed', $e->getMessage());
79 85
         }
80 86
     }
@@ -84,15 +90,21 @@  discard block
 block discarded – undo
84 90
      */
85 91
     public function testExceptionPHP8(): void
86 92
     {
87
-        try {
93
+        try
94
+        {
88 95
             \fopen('spiral://non-exists', 'rb');
89
-        } catch (\Throwable $e) {
96
+        }
97
+        catch (\Throwable $e)
98
+        {
90 99
             self::assertStringContainsString('Failed to open stream', $e->getMessage());
91 100
         }
92 101
 
93
-        try {
102
+        try
103
+        {
94 104
             \filemtime('spiral://non-exists');
95
-        } catch (\Throwable $e) {
105
+        }
106
+        catch (\Throwable $e)
107
+        {
96 108
             self::assertStringContainsString('stat failed', $e->getMessage());
97 109
         }
98 110
     }
Please login to merge, or discard this patch.
src/SendIt/tests/RenderTest.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
     public function defineDirectories(string $root): array
32 32
     {
33 33
         return [
34
-            'root' => __DIR__ . '/App',
35
-            'app'  => __DIR__ . '/App',
34
+            'root' => __DIR__.'/App',
35
+            'app'  => __DIR__.'/App',
36 36
         ] + parent::defineDirectories($root);
37 37
     }
38 38
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         parent::tearDown();
59 59
 
60
-        foreach (\glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file) {
60
+        foreach (\glob(__DIR__.'/App/runtime/cache/views/*.php') as $file){
61 61
             @\unlink($file);
62 62
         }
63 63
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,8 @@
 block discarded – undo
57 57
     {
58 58
         parent::tearDown();
59 59
 
60
-        foreach (\glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file) {
60
+        foreach (\glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file)
61
+        {
61 62
             @\unlink($file);
62 63
         }
63 64
     }
Please login to merge, or discard this patch.
src/SendIt/tests/JobTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,13 +50,13 @@
 block discarded – undo
50 50
 
51 51
         $this->mailer->expects('send')->with($email)->andThrow(new TransportException('failed'));
52 52
 
53
-        try {
53
+        try{
54 54
             $this->getHandler()->handle(
55 55
                 MailQueue::JOB_NAME,
56 56
                 'id',
57 57
                 \json_encode(MessageSerializer::pack($this->getMail())),
58 58
             );
59
-        } catch (TransportException) {
59
+        }catch (TransportException){
60 60
         }
61 61
     }
62 62
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,13 +50,16 @@
 block discarded – undo
50 50
 
51 51
         $this->mailer->expects('send')->with($email)->andThrow(new TransportException('failed'));
52 52
 
53
-        try {
53
+        try
54
+        {
54 55
             $this->getHandler()->handle(
55 56
                 MailQueue::JOB_NAME,
56 57
                 'id',
57 58
                 \json_encode(MessageSerializer::pack($this->getMail())),
58 59
             );
59
-        } catch (TransportException) {
60
+        }
61
+        catch (TransportException)
62
+        {
60 63
         }
61 64
     }
62 65
 
Please login to merge, or discard this patch.