|
@@ -81,25 +81,25 @@ discard block |
|
|
block discarded – undo |
|
81
|
81
|
if ($type instanceof ArrayTypeNode) { |
|
82
|
82
|
$resolvedType = $this->resolveTypeFromTypeNode($type->type, $reflectionProperty); |
|
83
|
83
|
|
|
84
|
|
- return 'array<' . $resolvedType . '>'; |
|
|
84
|
+ return 'array<'.$resolvedType.'>'; |
|
85
|
85
|
} |
|
86
|
86
|
|
|
87
|
87
|
// Generic array syntax: array<Product> | array<\Foo\Bar\Product> | array<int,Product> |
|
88
|
88
|
if ($type instanceof GenericTypeNode) { |
|
89
|
89
|
if ($this->isSimpleType($type->type, 'array')) { |
|
90
|
|
- $resolvedTypes = array_map(function (TypeNode $node) use ($reflectionProperty) { |
|
|
90
|
+ $resolvedTypes = array_map(function(TypeNode $node) use ($reflectionProperty) { |
|
91
|
91
|
return $this->resolveTypeFromTypeNode($node, $reflectionProperty); |
|
92
|
92
|
}, $type->genericTypes); |
|
93
|
93
|
|
|
94
|
|
- return 'array<' . implode(',', $resolvedTypes) . '>'; |
|
|
94
|
+ return 'array<'.implode(',', $resolvedTypes).'>'; |
|
95
|
95
|
} |
|
96
|
96
|
|
|
97
|
97
|
if ($this->isSimpleType($type->type, 'list')) { |
|
98
|
|
- $resolvedTypes = array_map(function (TypeNode $node) use ($reflectionProperty) { |
|
|
98
|
+ $resolvedTypes = array_map(function(TypeNode $node) use ($reflectionProperty) { |
|
99
|
99
|
return $this->resolveTypeFromTypeNode($node, $reflectionProperty); |
|
100
|
100
|
}, $type->genericTypes); |
|
101
|
101
|
|
|
102
|
|
- return 'array<int, ' . implode(',', $resolvedTypes) . '>'; |
|
|
102
|
+ return 'array<int, '.implode(',', $resolvedTypes).'>'; |
|
103
|
103
|
} |
|
104
|
104
|
|
|
105
|
105
|
throw new \InvalidArgumentException(sprintf("Can't use non-array generic type %s for collection in %s:%s", (string) $type->type, $reflectionProperty->getDeclaringClass()->getName(), $reflectionProperty->getName())); |
|
@@ -122,7 +122,7 @@ discard block |
|
|
block discarded – undo |
|
122
|
122
|
return []; |
|
123
|
123
|
} |
|
124
|
124
|
|
|
125
|
|
- return array_merge(...array_map(static function (VarTagValueNode $node) { |
|
|
125
|
+ return array_merge(...array_map(static function(VarTagValueNode $node) { |
|
126
|
126
|
if ($node->type instanceof UnionTypeNode) { |
|
127
|
127
|
return $node->type->types; |
|
128
|
128
|
} |
|
@@ -166,7 +166,7 @@ discard block |
|
|
block discarded – undo |
|
166
|
166
|
*/ |
|
167
|
167
|
private function filterNullFromTypes(array $types): array |
|
168
|
168
|
{ |
|
169
|
|
- return array_values(array_filter(array_map(function (TypeNode $node) { |
|
|
169
|
+ return array_values(array_filter(array_map(function(TypeNode $node) { |
|
170
|
170
|
return $this->isNullType($node) ? null : $node; |
|
171
|
171
|
}, $types))); |
|
172
|
172
|
} |
|
@@ -209,7 +209,7 @@ discard block |
|
|
block discarded – undo |
|
209
|
209
|
*/ |
|
210
|
210
|
private function resolveTypeFromTypeNode(TypeNode $typeNode, \ReflectionProperty $reflectionProperty): string |
|
211
|
211
|
{ |
|
212
|
|
- if (!($typeNode instanceof IdentifierTypeNode)) { |
|
|
212
|
+ if ( ! ($typeNode instanceof IdentifierTypeNode)) { |
|
213
|
213
|
throw new \InvalidArgumentException(sprintf("Can't use unsupported type %s for collection in %s:%s", (string) $typeNode, $reflectionProperty->getDeclaringClass()->getName(), $reflectionProperty->getName())); |
|
214
|
214
|
} |
|
215
|
215
|
|
|
@@ -222,7 +222,7 @@ discard block |
|
|
block discarded – undo |
|
222
|
222
|
return $typeHint; |
|
223
|
223
|
} |
|
224
|
224
|
|
|
225
|
|
- $expandedClassName = $declaringClass->getNamespaceName() . '\\' . $typeHint; |
|
|
225
|
+ $expandedClassName = $declaringClass->getNamespaceName().'\\'.$typeHint; |
|
226
|
226
|
if ($this->isClassOrInterface($expandedClassName)) { |
|
227
|
227
|
return $expandedClassName; |
|
228
|
228
|
} |
|
@@ -248,7 +248,7 @@ discard block |
|
|
block discarded – undo |
|
248
|
248
|
|
|
249
|
249
|
private function endsWith(string $statementClassToCheck, string $typeHintToSearchFor): bool |
|
250
|
250
|
{ |
|
251
|
|
- $typeHintToSearchFor = '\\' . $typeHintToSearchFor; |
|
|
251
|
+ $typeHintToSearchFor = '\\'.$typeHintToSearchFor; |
|
252
|
252
|
|
|
253
|
253
|
return substr($statementClassToCheck, -strlen($typeHintToSearchFor)) === $typeHintToSearchFor; |
|
254
|
254
|
} |
|
@@ -269,7 +269,7 @@ discard block |
|
|
block discarded – undo |
|
269
|
269
|
preg_match_all(self::GROUP_USE_STATEMENTS_REGEX, $classContents, $foundGroupUseStatements); |
|
270
|
270
|
for ($useStatementIndex = 0; $useStatementIndex < count($foundGroupUseStatements[0]); $useStatementIndex++) { |
|
271
|
271
|
foreach (explode(',', $foundGroupUseStatements[2][$useStatementIndex]) as $singleUseStatement) { |
|
272
|
|
- $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]) . trim($singleUseStatement); |
|
|
272
|
+ $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]).trim($singleUseStatement); |
|
273
|
273
|
} |
|
274
|
274
|
} |
|
275
|
275
|
|
|
@@ -302,7 +302,7 @@ discard block |
|
|
block discarded – undo |
|
302
|
302
|
|
|
303
|
303
|
private function resolveType(string $typeHint, \ReflectionProperty $reflectionProperty): string |
|
304
|
304
|
{ |
|
305
|
|
- if (!$this->hasGlobalNamespacePrefix($typeHint) && !$this->isPrimitiveType($typeHint)) { |
|
|
305
|
+ if ( ! $this->hasGlobalNamespacePrefix($typeHint) && ! $this->isPrimitiveType($typeHint)) { |
|
306
|
306
|
$typeHint = $this->expandClassNameUsingUseStatements($typeHint, $this->getDeclaringClassOrTrait($reflectionProperty), $reflectionProperty); |
|
307
|
307
|
} |
|
308
|
308
|
|
|
@@ -317,7 +317,7 @@ discard block |
|
|
block discarded – undo |
|
317
|
317
|
private function resolveTypeFromDocblock(\ReflectionProperty $reflectionProperty): ?array |
|
318
|
318
|
{ |
|
319
|
319
|
$docComment = $reflectionProperty->getDocComment(); |
|
320
|
|
- if (!$docComment && PHP_VERSION_ID >= 80000 && $reflectionProperty->isPromoted()) { |
|
|
320
|
+ if ( ! $docComment && PHP_VERSION_ID >= 80000 && $reflectionProperty->isPromoted()) { |
|
321
|
321
|
$docComment = $reflectionProperty->getDeclaringClass()->getConstructor()->getDocComment(); |
|
322
|
322
|
|
|
323
|
323
|
$tokens = $this->lexer->tokenize($docComment); |
|
@@ -326,7 +326,7 @@ discard block |
|
|
block discarded – undo |
|
326
|
326
|
return $this->flattenParamTagValueTypes($reflectionProperty->getName(), $phpDocNode->getParamTagValues()); |
|
327
|
327
|
} |
|
328
|
328
|
|
|
329
|
|
- if (!$docComment) { |
|
|
329
|
+ if ( ! $docComment) { |
|
330
|
330
|
return null; |
|
331
|
331
|
} |
|
332
|
332
|
|