Completed
Pull Request — master (#137)
by Alexander
22:49
created
src/Traits/ReflectionClassLikeTrait.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     /**
88 88
      * Parent class, or false if not present, null if uninitialized yet
89 89
      */
90
-    protected null|\ReflectionClass|false $parentClass;
90
+    protected null | \ReflectionClass | false $parentClass;
91 91
 
92 92
     /**
93 93
      * @var ReflectionProperty[]
@@ -136,19 +136,19 @@  discard block
 block discarded – undo
136 136
             }
137 137
         }
138 138
 
139
-        $buildString = static function (array $items, $indentLevel = 4) {
139
+        $buildString = static function(array $items, $indentLevel = 4) {
140 140
             if (!count($items)) {
141 141
                 return '';
142 142
             }
143
-            $indent = "\n" . str_repeat(' ', $indentLevel);
143
+            $indent = "\n".str_repeat(' ', $indentLevel);
144 144
 
145
-            return $indent . implode($indent, explode("\n", implode("\n", $items)));
145
+            return $indent.implode($indent, explode("\n", implode("\n", $items)));
146 146
         };
147 147
 
148
-        $buildConstants = static function (array $items, $indentLevel = 4) {
148
+        $buildConstants = static function(array $items, $indentLevel = 4) {
149 149
             $str = '';
150 150
             foreach ($items as $name => $value) {
151
-                $str .= "\n" . str_repeat(' ', $indentLevel);
151
+                $str .= "\n".str_repeat(' ', $indentLevel);
152 152
                 $str .= sprintf(
153 153
                     'Constant [ %s %s ] { %s }',
154 154
                     gettype($value),
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 
171 171
         $string = sprintf(
172 172
             $format,
173
-            $this->getDocComment() ? $this->getDocComment() . "\n" : '',
173
+            $this->getDocComment() ? $this->getDocComment()."\n" : '',
174 174
             ($isObject ? 'Object of class' : 'Class'),
175 175
             $modifiers,
176 176
             $this->getName(),
177
-            false !== $parentClass ? (' extends ' . $parentClass->getName()) : '',
178
-            $interfaceNames ? (' implements ' . implode(', ', $interfaceNames)) : '',
177
+            false !== $parentClass ? (' extends '.$parentClass->getName()) : '',
178
+            $interfaceNames ? (' implements '.implode(', ', $interfaceNames)) : '',
179 179
             $this->getFileName(),
180 180
             $this->getStartLine(),
181 181
             $this->getEndLine(),
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     {
217 217
         if (!isset($this->constants)) {
218 218
             $this->constants = $this->recursiveCollect(
219
-                function (array &$result, \ReflectionClass $instance) {
219
+                function(array &$result, \ReflectionClass $instance) {
220 220
                     $result += $instance->getConstants();
221 221
                 }
222 222
             );
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
     /**
284 284
      * {@inheritDoc}
285 285
      */
286
-    public function getDocComment(): string|false
286
+    public function getDocComment(): string | false
287 287
     {
288 288
         $docComment = $this->classLikeNode->getDocComment();
289 289
 
290 290
         return $docComment ? $docComment->getText() : false;
291 291
     }
292 292
 
293
-    public function getEndLine(): int|false
293
+    public function getEndLine(): int | false
294 294
     {
295 295
         return $this->classLikeNode->getAttribute('endLine');
296 296
     }
@@ -300,12 +300,12 @@  discard block
 block discarded – undo
300 300
         return null;
301 301
     }
302 302
 
303
-    public function getExtensionName(): string|false
303
+    public function getExtensionName(): string | false
304 304
     {
305 305
         return false;
306 306
     }
307 307
 
308
-    public function getFileName(): string|false
308
+    public function getFileName(): string | false
309 309
     {
310 310
         return $this->classLikeNode->getAttribute('fileName');
311 311
     }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
     {
326 326
         if (!isset($this->interfaceClasses)) {
327 327
             $this->interfaceClasses = $this->recursiveCollect(
328
-                function (array &$result, \ReflectionClass $instance) {
328
+                function(array &$result, \ReflectionClass $instance) {
329 329
                     if ($instance->isInterface()) {
330 330
                         $result[$instance->name] = $instance;
331 331
                     }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             }
351 351
         }
352 352
 
353
-        throw new ReflectionException("Method " . $this->getName() . "::" . $name . " does not exist");
353
+        throw new ReflectionException("Method ".$this->getName()."::".$name." does not exist");
354 354
     }
355 355
 
356 356
     /**
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
      *
359 359
      * @return ReflectionMethod[]
360 360
      */
361
-    public function getMethods(int|null $filter = null): array
361
+    public function getMethods(int | null $filter = null): array
362 362
     {
363 363
         if (!isset($this->methods)) {
364 364
             $directMethods = ReflectionMethod::collectFromClassNode($this->classLikeNode, $this);
365 365
             $parentMethods = $this->recursiveCollect(
366
-                function (array &$result, \ReflectionClass $instance, $isParent) {
366
+                function(array &$result, \ReflectionClass $instance, $isParent) {
367 367
                     $reflectionMethods = [];
368 368
                     foreach ($instance->getMethods() as $reflectionMethod) {
369 369
                         if (!$isParent || !$reflectionMethod->isPrivate()) {
@@ -432,9 +432,9 @@  discard block
 block discarded – undo
432 432
      */
433 433
     public function getName(): string
434 434
     {
435
-        $namespaceName = $this->namespaceName ? $this->namespaceName . '\\' : '';
435
+        $namespaceName = $this->namespaceName ? $this->namespaceName.'\\' : '';
436 436
 
437
-        return $namespaceName . $this->getShortName();
437
+        return $namespaceName.$this->getShortName();
438 438
     }
439 439
 
440 440
     /**
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
     /**
449 449
      * {@inheritDoc}
450 450
      */
451
-    public function getParentClass(): \ReflectionClass|false
451
+    public function getParentClass(): \ReflectionClass | false
452 452
     {
453 453
         if (!isset($this->parentClass)) {
454 454
 
@@ -472,12 +472,12 @@  discard block
 block discarded – undo
472 472
      *
473 473
      * @return ReflectionProperty[]
474 474
      */
475
-    public function getProperties(int|null $filter = null): array
475
+    public function getProperties(int | null $filter = null): array
476 476
     {
477 477
         if (!isset($this->properties)) {
478 478
             $directProperties = ReflectionProperty::collectFromClassNode($this->classLikeNode, $this->getName());
479 479
             $parentProperties = $this->recursiveCollect(
480
-                function (array &$result, \ReflectionClass $instance, $isParent) {
480
+                function(array &$result, \ReflectionClass $instance, $isParent) {
481 481
                     $reflectionProperties = [];
482 482
                     foreach ($instance->getProperties() as $reflectionProperty) {
483 483
                         if (!$isParent || !$reflectionProperty->isPrivate()) {
@@ -520,13 +520,13 @@  discard block
 block discarded – undo
520 520
             }
521 521
         }
522 522
 
523
-        throw new ReflectionException("Property " . $this->getName() . "::" . $name . " does not exist");
523
+        throw new ReflectionException("Property ".$this->getName()."::".$name." does not exist");
524 524
     }
525 525
 
526 526
     /**
527 527
      * @inheritDoc
528 528
      */
529
-    public function getReflectionConstant(string $name): \ReflectionClassConstant|false
529
+    public function getReflectionConstant(string $name): \ReflectionClassConstant | false
530 530
     {
531 531
         $classConstants = $this->getReflectionConstants();
532 532
         foreach ($classConstants as $classConstant) {
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
                 $this->getName()
550 550
             );
551 551
             $parentClassConstants = $this->recursiveCollect(
552
-                function (array &$result, \ReflectionClass $instance, $isParent) {
552
+                function(array &$result, \ReflectionClass $instance, $isParent) {
553 553
                     $reflectionClassConstants = [];
554 554
                     foreach ($instance->getReflectionConstants() as $reflectionClassConstant) {
555 555
                         if (!$isParent || !$reflectionClassConstant->isPrivate()) {
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
         return $this->className;
576 576
     }
577 577
 
578
-    public function getStartLine(): int|false
578
+    public function getStartLine(): int | false
579 579
     {
580 580
         if ($this->classLikeNode->attrGroups !== []) {
581 581
             $attrGroups = $this->classLikeNode->attrGroups;
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
                         break;
610 610
                     }
611 611
                 }
612
-                $aliases[$adaptation->newName] = $traitName . '::' . $methodName;
612
+                $aliases[$adaptation->newName] = $traitName.'::'.$methodName;
613 613
             }
614 614
         }
615 615
 
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
     /**
691 691
      * {@inheritDoc}
692 692
      */
693
-    public function implementsInterface(\ReflectionClass|string $interfaceName): bool
693
+    public function implementsInterface(\ReflectionClass | string $interfaceName): bool
694 694
     {
695 695
         $allInterfaces = $this->getInterfaces();
696 696
 
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
     /**
830 830
      * {@inheritDoc}
831 831
      */
832
-    public function isSubclassOf(\ReflectionClass|string $class): bool
832
+    public function isSubclassOf(\ReflectionClass | string $class): bool
833 833
     {
834 834
         if ($class instanceof \ReflectionClass) {
835 835
             $className = $class->name;
Please login to merge, or discard this patch.
src/Resolver/TypeExpressionResolver.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
      * Current reflection context for parsing
41 41
      */
42 42
     private
43
-        \ReflectionClass|\ReflectionFunction|\ReflectionMethod|\ReflectionClassConstant|
44
-        \ReflectionParameter|\ReflectionAttribute|\ReflectionProperty|ReflectionFileNamespace|null $context;
43
+        \ReflectionClass | \ReflectionFunction | \ReflectionMethod | \ReflectionClassConstant |
44
+        \ReflectionParameter | \ReflectionAttribute | \ReflectionProperty | ReflectionFileNamespace | null $context;
45 45
 
46 46
     /**
47 47
      * Whether this type has explicit null value set
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     private array $nodeStack = [];
60 60
 
61
-    private \ReflectionNamedType|\ReflectionUnionType|\ReflectionIntersectionType|null $type;
61
+    private \ReflectionNamedType | \ReflectionUnionType | \ReflectionIntersectionType | null $type;
62 62
 
63 63
     public function __construct($context)
64 64
     {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $this->type           = $this->resolve($node);
77 77
     }
78 78
 
79
-    final public function getType(): \ReflectionNamedType|\ReflectionUnionType|\ReflectionIntersectionType|null
79
+    final public function getType(): \ReflectionNamedType | \ReflectionUnionType | \ReflectionIntersectionType | null
80 80
     {
81 81
         return $this->type;
82 82
     }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
             $methodName = $this->getDispatchMethodFor($node);
97 97
             if (!method_exists($this, $methodName)) {
98
-                throw new ReflectionException("Could not find handler for the " . __CLASS__ . "::{$methodName} method");
98
+                throw new ReflectionException("Could not find handler for the ".__CLASS__."::{$methodName} method");
99 99
             }
100 100
             $type = $this->$methodName($node);
101 101
         } finally {
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     private function resolveUnionType(Node\UnionType $unionType): ReflectionUnionType
110 110
     {
111 111
         $resolvedTypes = array_map(
112
-            fn(Identifier|IntersectionType|Name $singleType) => $this->resolve($singleType),
112
+            fn(Identifier | IntersectionType | Name $singleType) => $this->resolve($singleType),
113 113
             $unionType->types
114 114
         );
115 115
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     private function resolveIntersectionType(Node\IntersectionType $intersectionType): ReflectionIntersectionType
120 120
     {
121 121
         $resolvedTypes = array_map(
122
-            fn(Identifier|IntersectionType|Name $singleType) => $this->resolve($singleType),
122
+            fn(Identifier | IntersectionType | Name $singleType) => $this->resolve($singleType),
123 123
             $intersectionType->types
124 124
         );
125 125
 
@@ -159,6 +159,6 @@  discard block
 block discarded – undo
159 159
     {
160 160
         $nodeType = $node->getType();
161 161
 
162
-        return 'resolve' . str_replace('_', '', $nodeType);
162
+        return 'resolve'.str_replace('_', '', $nodeType);
163 163
     }
164 164
 }
Please login to merge, or discard this patch.
src/Resolver/NodeExpressionResolver.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
      * Current reflection context for parsing
51 51
      */
52 52
     private
53
-        \ReflectionClass|\ReflectionFunction|\ReflectionMethod|\ReflectionClassConstant|
54
-        \ReflectionParameter|\ReflectionAttribute|\ReflectionProperty|ReflectionFileNamespace|null $context;
53
+        \ReflectionClass | \ReflectionFunction | \ReflectionMethod | \ReflectionClassConstant |
54
+        \ReflectionParameter | \ReflectionAttribute | \ReflectionProperty | ReflectionFileNamespace | null $context;
55 55
 
56 56
     /**
57 57
      * Flag if given expression is constant
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                     $node->name = new Name(ltrim($constantNodeName->toString(), '\\'));
124 124
                 } else {
125 125
                     // For relative names we would like to add namespace prefix
126
-                    $node->name = new Name($this->resolveScalarMagicConstNamespace() . '\\' . $constantNodeName->toString());
126
+                    $node->name = new Name($this->resolveScalarMagicConstNamespace().'\\'.$constantNodeName->toString());
127 127
                 }
128 128
             }
129 129
             // All long array nodes are pretty-printed by PHP in short format
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
             $methodName = $this->getDispatchMethodFor($node);
170 170
             if (!method_exists($this, $methodName)) {
171
-                throw new ReflectionException("Could not find handler for the " . __CLASS__ . "::{$methodName} method");
171
+                throw new ReflectionException("Could not find handler for the ".__CLASS__."::{$methodName} method");
172 172
             }
173 173
             $value = $this->$methodName($node);
174 174
         } finally {
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             throw new ReflectionException("Could not resolve __METHOD__ without method context");
256 256
         }
257 257
 
258
-        return $this->context->getDeclaringClass()->name . '::' . $this->context->getShortName();
258
+        return $this->context->getDeclaringClass()->name.'::'.$this->context->getShortName();
259 259
     }
260 260
 
261 261
     /**
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             $fileNamespace = new ReflectionFileNamespace($fileName, $namespaceName);
362 362
             if ($fileNamespace->hasConstant($constantName)) {
363 363
                 $constantValue = $fileNamespace->getConstant($constantName);
364
-                $constantName  = $fileNamespace->getName() . '\\' . $constantName;
364
+                $constantName  = $fileNamespace->getName().'\\'.$constantName;
365 365
                 $isResolved    = true;
366 366
             }
367 367
         }
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
         if (!$isResolved && defined($constantName)) {
371 371
             $constantValue = constant($constantName);
372 372
             if (!$isFQNConstant) {
373
-                $constantName  = $this->context->getNamespaceName() . '\\' . $constantName;
373
+                $constantName = $this->context->getNamespaceName().'\\'.$constantName;
374 374
             }
375 375
         }
376 376
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 
417 417
         $this->isConstant   = true;
418 418
         $this->isConstExpr  = true;
419
-        $this->constantName = $classToReflectNodeName . '::' . $constantName;
419
+        $this->constantName = $classToReflectNodeName.'::'.$constantName;
420 420
 
421 421
         return $refClass->getConstant($constantName);
422 422
     }
@@ -436,27 +436,27 @@  discard block
 block discarded – undo
436 436
         return $result;
437 437
     }
438 438
 
439
-    protected function resolveExprBinaryOpPlus(Expr\BinaryOp\Plus $node): int|float|array
439
+    protected function resolveExprBinaryOpPlus(Expr\BinaryOp\Plus $node): int | float | array
440 440
     {
441 441
         return $this->resolve($node->left) + $this->resolve($node->right);
442 442
     }
443 443
 
444
-    protected function resolveExprBinaryOpMinus(Expr\BinaryOp\Minus $node): int|float
444
+    protected function resolveExprBinaryOpMinus(Expr\BinaryOp\Minus $node): int | float
445 445
     {
446 446
         return $this->resolve($node->left) - $this->resolve($node->right);
447 447
     }
448 448
 
449
-    protected function resolveExprBinaryOpMul(Expr\BinaryOp\Mul $node): int|float
449
+    protected function resolveExprBinaryOpMul(Expr\BinaryOp\Mul $node): int | float
450 450
     {
451 451
         return $this->resolve($node->left) * $this->resolve($node->right);
452 452
     }
453 453
 
454
-    protected function resolveExprBinaryOpPow(Expr\BinaryOp\Pow $node): int|float
454
+    protected function resolveExprBinaryOpPow(Expr\BinaryOp\Pow $node): int | float
455 455
     {
456 456
         return $this->resolve($node->left) ** $this->resolve($node->right);
457 457
     }
458 458
 
459
-    protected function resolveExprBinaryOpDiv(Expr\BinaryOp\Div $node): int|float
459
+    protected function resolveExprBinaryOpDiv(Expr\BinaryOp\Div $node): int | float
460 460
     {
461 461
         return $this->resolve($node->left) / $this->resolve($node->right);
462 462
     }
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
         return !$this->resolve($node->expr);
477 477
     }
478 478
 
479
-    protected function resolveExprBitwiseNot(Expr\BitwiseNot $node): int|string
479
+    protected function resolveExprBitwiseNot(Expr\BitwiseNot $node): int | string
480 480
     {
481 481
         return ~$this->resolve($node->expr);
482 482
     }
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 
509 509
     protected function resolveExprBinaryOpConcat(Expr\BinaryOp\Concat $node): string
510 510
     {
511
-        return $this->resolve($node->left) . $this->resolve($node->right);
511
+        return $this->resolve($node->left).$this->resolve($node->right);
512 512
     }
513 513
 
514 514
     protected function resolveExprTernary(Expr\Ternary $node): mixed
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
     {
594 594
         $nodeType = $node->getType();
595 595
 
596
-        return 'resolve' . str_replace('_', '', $nodeType);
596
+        return 'resolve'.str_replace('_', '', $nodeType);
597 597
     }
598 598
 
599 599
     /**
Please login to merge, or discard this patch.