@@ -67,14 +67,14 @@ |
||
67 | 67 | if ($type instanceof ReflectionNamedType) { |
68 | 68 | $displayType = $type->getName(); |
69 | 69 | } else { |
70 | - $displayType = (string)$type; |
|
70 | + $displayType = (string) $type; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $displayType = ltrim($displayType, '\\'); |
74 | 74 | |
75 | 75 | $specialNullableTypes = in_array($displayType, ['mixed', 'null'], true); |
76 | 76 | if ($type->allowsNull() && !$type instanceof ReflectionUnionType && !$specialNullableTypes) { |
77 | - $displayType = '?' . $displayType; |
|
77 | + $displayType = '?'.$displayType; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | return $displayType; |
@@ -34,15 +34,15 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * Concrete class constant node |
36 | 36 | */ |
37 | - private ClassConst|EnumCase $classConstOrEnumCaseNode; |
|
37 | + private ClassConst | EnumCase $classConstOrEnumCaseNode; |
|
38 | 38 | |
39 | - private Const_|EnumCase $constOrEnumCaseNode; |
|
39 | + private Const_ | EnumCase $constOrEnumCaseNode; |
|
40 | 40 | |
41 | 41 | private string $className; |
42 | 42 | |
43 | 43 | private mixed $value = null; |
44 | 44 | |
45 | - private \ReflectionUnionType|\ReflectionNamedType|\ReflectionIntersectionType|null $type = null; |
|
45 | + private \ReflectionUnionType | \ReflectionNamedType | \ReflectionIntersectionType | null $type = null; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Parses class constants from the concrete class node |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | public function __construct( |
87 | 87 | string $className, |
88 | 88 | string $classConstantName, |
89 | - ClassConst|EnumCase|null $classConstNode = null, |
|
90 | - Const_|EnumCase|null $constNode = null |
|
89 | + ClassConst | EnumCase | null $classConstNode = null, |
|
90 | + Const_ | EnumCase | null $constNode = null |
|
91 | 91 | ) { |
92 | 92 | $this->className = ltrim($className, '\\'); |
93 | 93 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * @inheritDoc |
143 | 143 | */ |
144 | - public function getDocComment(): string|false |
|
144 | + public function getDocComment(): string | false |
|
145 | 145 | { |
146 | 146 | $docBlock = $this->classConstOrEnumCaseNode->getDocComment(); |
147 | 147 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | ]; |
256 | 256 | $value = $this->isEnumCase() ? 'Object' : $this->getValue(); |
257 | 257 | if (!$this->hasType()) { |
258 | - $type = gettype($value); |
|
258 | + $type = gettype($value); |
|
259 | 259 | if (isset($typeMap[$type])) { |
260 | 260 | $type = $typeMap[$type]; |
261 | 261 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | ); |
279 | 279 | } |
280 | 280 | |
281 | - public function getNode(): ClassConst|EnumCase |
|
281 | + public function getNode(): ClassConst | EnumCase |
|
282 | 282 | { |
283 | 283 | return $this->classConstOrEnumCaseNode; |
284 | 284 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * |
36 | 36 | * @param string $className Name of the class |
37 | 37 | */ |
38 | - public function locateClass(string $className): false|string |
|
38 | + public function locateClass(string $className): false | string |
|
39 | 39 | { |
40 | 40 | return call_user_func($this->callable, ltrim($className, '\\')); |
41 | 41 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * |
51 | 51 | * @param string $className Name of the class |
52 | 52 | **/ |
53 | - public function locateClass(string $className): false|string |
|
53 | + public function locateClass(string $className): false | string |
|
54 | 54 | { |
55 | 55 | $filePath = $this->loader->findFile(ltrim($className, '\\')); |
56 | 56 | if (!empty($filePath)) { |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | |
75 | 75 | private ?string $defaultValueConstExpr; |
76 | 76 | |
77 | - private \ReflectionUnionType|\ReflectionNamedType|\ReflectionIntersectionType|null $type = null; |
|
77 | + private \ReflectionUnionType | \ReflectionNamedType | \ReflectionIntersectionType | null $type = null; |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Initializes a reflection for the property |
81 | 81 | */ |
82 | 82 | public function __construct( |
83 | - string|array $unusedFunctionName, |
|
83 | + string | array $unusedFunctionName, |
|
84 | 84 | string $parameterName, |
85 | 85 | Param $parameterNode, |
86 | 86 | int $parameterIndex, |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | public function __debugInfo(): array |
136 | 136 | { |
137 | 137 | return [ |
138 | - 'name' => (string)$this->parameterNode->var->name, |
|
138 | + 'name' => (string) $this->parameterNode->var->name, |
|
139 | 139 | ]; |
140 | 140 | } |
141 | 141 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | // For constant fetch expressions, PHP renders now expression |
153 | 153 | if ($this->isDefaultValueConstExpr) { |
154 | 154 | $defaultValue = $this->defaultValueConstExpr; |
155 | - } elseif ($this->isDefaultValueConstant){ |
|
155 | + } elseif ($this->isDefaultValueConstant) { |
|
156 | 156 | $defaultValue = $this->defaultValueConstantName; |
157 | 157 | } else { |
158 | 158 | $defaultValue = var_export($this->getDefaultValue(), true); |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | 'Parameter #%d [ %s %s%s%s$%s%s ]', |
164 | 164 | $this->parameterIndex, |
165 | 165 | $isOptional ? '<optional>' : '<required>', |
166 | - $parameterType ? ReflectionType::convertToDisplayType($parameterType) . ' ' : '', |
|
166 | + $parameterType ? ReflectionType::convertToDisplayType($parameterType).' ' : '', |
|
167 | 167 | $this->isVariadic() ? '...' : '', |
168 | 168 | $this->isPassedByReference() ? '&' : '', |
169 | 169 | $this->getName(), |
170 | - ($isOptional && $hasDefaultValue) ? (' = ' . $defaultValue) : '' |
|
170 | + ($isOptional && $hasDefaultValue) ? (' = '.$defaultValue) : '' |
|
171 | 171 | ); |
172 | 172 | } |
173 | 173 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | /** |
263 | 263 | * {@inheritDoc} |
264 | 264 | */ |
265 | - public function getDefaultValueConstantName(): null|string |
|
265 | + public function getDefaultValueConstantName(): null | string |
|
266 | 266 | { |
267 | 267 | if (!$this->isDefaultValueAvailable()) { |
268 | 268 | throw new ReflectionException('Internal error: Failed to retrieve the default value'); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function getName(): string |
278 | 278 | { |
279 | - return (string)$this->parameterNode->var->name; |
|
279 | + return (string) $this->parameterNode->var->name; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | /** |
291 | 291 | * @inheritDoc |
292 | 292 | */ |
293 | - public function getType(): \ReflectionNamedType|\ReflectionUnionType|\ReflectionIntersectionType|null |
|
293 | + public function getType(): \ReflectionNamedType | \ReflectionUnionType | \ReflectionIntersectionType | null |
|
294 | 294 | { |
295 | 295 | return $this->type; |
296 | 296 | } |
@@ -66,7 +66,7 @@ |
||
66 | 66 | return $this->fileNamespaces[$namespaceName]; |
67 | 67 | } |
68 | 68 | |
69 | - throw new ReflectionException("Could not find the namespace " . $namespaceName . " in the file " . $this->fileName); |
|
69 | + throw new ReflectionException("Could not find the namespace ".$namespaceName." in the file ".$this->fileName); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -13,8 +13,8 @@ |
||
13 | 13 | |
14 | 14 | return RectorConfig::configure() |
15 | 15 | ->withPaths([ |
16 | - __DIR__ . '/src', |
|
17 | - __DIR__ . '/tests', |
|
16 | + __DIR__.'/src', |
|
17 | + __DIR__.'/tests', |
|
18 | 18 | ]) |
19 | 19 | // uncomment to reach your current PHP version |
20 | 20 | // ->withPhpSets() |
@@ -87,7 +87,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -40,8 +40,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |