@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | if (false !== stripos($data, '<!doctype')) { |
87 | 87 | $internalSubset = $this->getDomDocumentTypeEntitySubset($data); |
88 | - if (!in_array($internalSubset, $this->doctypeAllowList, true)) { |
|
88 | + if ( ! in_array($internalSubset, $this->doctypeAllowList, true)) { |
|
89 | 89 | throw new InvalidArgumentException(sprintf( |
90 | 90 | 'The document type "%s" is not allowed. If it is safe, you may add it to the allowlist configuration.', |
91 | 91 | $internalSubset |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $nodes = $data->xpath($entryName); |
220 | 220 | } |
221 | 221 | |
222 | - if (null === $nodes || !\count($nodes)) { |
|
222 | + if (null === $nodes || ! \count($nodes)) { |
|
223 | 223 | return []; |
224 | 224 | } |
225 | 225 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $nodes = $data->children($namespace)->$entryName; |
248 | 248 | foreach ($nodes as $v) { |
249 | 249 | $attrs = $v->attributes(); |
250 | - if (!isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
250 | + if ( ! isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
251 | 251 | throw new RuntimeException(sprintf('The key attribute "%s" must be set for each entry of the map.', $this->currentMetadata->xmlKeyAttribute)); |
252 | 252 | } |
253 | 253 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | return (string) $data->attributes($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}; |
278 | 278 | |
279 | 279 | // Check XML element with namespace for discriminatorFieldName |
280 | - case !$metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}): |
|
280 | + case ! $metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}): |
|
281 | 281 | return (string) $data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}; |
282 | 282 | |
283 | 283 | // Check XML element for discriminatorFieldName |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $name = $metadata->serializedName; |
308 | 308 | |
309 | 309 | if (true === $metadata->inline) { |
310 | - if (!$metadata->type) { |
|
310 | + if ( ! $metadata->type) { |
|
311 | 311 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
312 | 312 | } |
313 | 313 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | if ($metadata->xmlAttribute) { |
318 | 318 | $attributes = $data->attributes($metadata->xmlNamespace); |
319 | 319 | if (isset($attributes[$name])) { |
320 | - if (!$metadata->type) { |
|
320 | + if ( ! $metadata->type) { |
|
321 | 321 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
322 | 322 | } |
323 | 323 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | if ($metadata->xmlValue) { |
331 | - if (!$metadata->type) { |
|
331 | + if ( ! $metadata->type) { |
|
332 | 332 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
333 | 333 | } |
334 | 334 | |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | |
338 | 338 | if ($metadata->xmlCollection) { |
339 | 339 | $enclosingElem = $data; |
340 | - if (!$metadata->xmlCollectionInline) { |
|
340 | + if ( ! $metadata->xmlCollectionInline) { |
|
341 | 341 | $enclosingElem = $data->children($metadata->xmlNamespace)->$name; |
342 | 342 | } |
343 | 343 | |
344 | 344 | $this->setCurrentMetadata($metadata); |
345 | - if (!$metadata->type) { |
|
345 | + if ( ! $metadata->type) { |
|
346 | 346 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
347 | 347 | } |
348 | 348 | |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | |
355 | 355 | if ($metadata->xmlNamespace) { |
356 | 356 | $node = $data->children($metadata->xmlNamespace)->$name; |
357 | - if (!$node->count()) { |
|
357 | + if ( ! $node->count()) { |
|
358 | 358 | throw new NotAcceptableException(); |
359 | 359 | } |
360 | 360 | } elseif ('' === $metadata->xmlNamespace) { |
361 | 361 | // See #1087 - element must be like: <element xmlns="" /> - https://www.w3.org/TR/REC-xml-names/#iri-use |
362 | 362 | // Use of an empty string in a namespace declaration turns it into an "undeclaration". |
363 | - $nodes = $data->xpath('./' . $name); |
|
363 | + $nodes = $data->xpath('./'.$name); |
|
364 | 364 | if (empty($nodes)) { |
365 | 365 | throw new NotAcceptableException(); |
366 | 366 | } |
@@ -371,9 +371,9 @@ discard block |
||
371 | 371 | if (isset($namespaces[''])) { |
372 | 372 | $prefix = uniqid('ns-'); |
373 | 373 | $data->registerXPathNamespace($prefix, $namespaces['']); |
374 | - $nodes = $data->xpath('./' . $prefix . ':' . $name); |
|
374 | + $nodes = $data->xpath('./'.$prefix.':'.$name); |
|
375 | 375 | } else { |
376 | - $nodes = $data->xpath('./' . $name); |
|
376 | + $nodes = $data->xpath('./'.$name); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | if (empty($nodes)) { |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $this->setCurrentMetadata($metadata); |
388 | 388 | } |
389 | 389 | |
390 | - if (!$metadata->type) { |
|
390 | + if ( ! $metadata->type) { |
|
391 | 391 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
392 | 392 | } |
393 | 393 |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public function loadMetadataForClass(\ReflectionClass $class): ?BaseClassMetadata |
72 | 72 | { |
73 | 73 | $classMetadata = new ClassMetadata($name = $class->name); |
74 | - $fileResource = $class->getFilename(); |
|
74 | + $fileResource = $class->getFilename(); |
|
75 | 75 | |
76 | 76 | if (false !== $fileResource) { |
77 | 77 | $classMetadata->fileResources[] = $fileResource; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - if (!$excludeAll) { |
|
156 | + if ( ! $excludeAll) { |
|
157 | 157 | foreach ($class->getProperties() as $property) { |
158 | 158 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
159 | 159 | continue; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } elseif ($annot instanceof Expose) { |
186 | 186 | $isExpose = true; |
187 | 187 | if (null !== $annot->if) { |
188 | - $propertyMetadata->excludeIf = $this->parseExpression('!(' . $annot->if . ')'); |
|
188 | + $propertyMetadata->excludeIf = $this->parseExpression('!('.$annot->if.')'); |
|
189 | 189 | } |
190 | 190 | } elseif ($annot instanceof Exclude) { |
191 | 191 | if (null !== $annot->if) { |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | throw new InvalidMetadataException(sprintf( |
233 | 233 | 'Invalid group name "%s" on "%s", did you mean to create multiple groups?', |
234 | 234 | implode(', ', $propertyMetadata->groups), |
235 | - $propertyMetadata->class . '->' . $propertyMetadata->name |
|
235 | + $propertyMetadata->class.'->'.$propertyMetadata->name |
|
236 | 236 | )); |
237 | 237 | } |
238 | 238 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | - if (!$propertyMetadata->serializedName) { |
|
257 | + if ( ! $propertyMetadata->serializedName) { |
|
258 | 258 | $propertyMetadata->serializedName = $this->namingStrategy->translateName($propertyMetadata); |
259 | 259 | } |
260 | 260 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | if ( |
268 | - (ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
268 | + (ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
269 | 269 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
270 | 270 | ) { |
271 | 271 | $propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | protected function getClassAnnotations(\ReflectionClass $class): array |
13 | 13 | { |
14 | 14 | return array_map( |
15 | - static function (\ReflectionAttribute $attribute): object { |
|
15 | + static function(\ReflectionAttribute $attribute): object { |
|
16 | 16 | return $attribute->newInstance(); |
17 | 17 | }, |
18 | 18 | $class->getAttributes() |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | protected function getMethodAnnotations(\ReflectionMethod $method): array |
26 | 26 | { |
27 | 27 | return array_map( |
28 | - static function (\ReflectionAttribute $attribute): object { |
|
28 | + static function(\ReflectionAttribute $attribute): object { |
|
29 | 29 | return $attribute->newInstance(); |
30 | 30 | }, |
31 | 31 | $method->getAttributes() |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | protected function getPropertyAnnotations(\ReflectionProperty $property): array |
39 | 39 | { |
40 | 40 | return array_map( |
41 | - static function (\ReflectionAttribute $attribute): object { |
|
41 | + static function(\ReflectionAttribute $attribute): object { |
|
42 | 42 | return $attribute->newInstance(); |
43 | 43 | }, |
44 | 44 | $property->getAttributes() |
@@ -123,7 +123,7 @@ |
||
123 | 123 | */ |
124 | 124 | private function shouldTypeHint(?ReflectionType $reflectionType): bool |
125 | 125 | { |
126 | - if (!$reflectionType instanceof ReflectionNamedType) { |
|
126 | + if ( ! $reflectionType instanceof ReflectionNamedType) { |
|
127 | 127 | return false; |
128 | 128 | } |
129 | 129 |
@@ -108,25 +108,25 @@ discard block |
||
108 | 108 | if ($type instanceof ArrayTypeNode) { |
109 | 109 | $resolvedType = $this->resolveTypeFromTypeNode($type->type, $reflector); |
110 | 110 | |
111 | - return 'array<' . $resolvedType . '>'; |
|
111 | + return 'array<'.$resolvedType.'>'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | // Generic array syntax: array<Product> | array<\Foo\Bar\Product> | array<int,Product> |
115 | 115 | if ($type instanceof GenericTypeNode) { |
116 | 116 | if ($this->isSimpleType($type->type, 'array')) { |
117 | - $resolvedTypes = array_map(function (TypeNode $node) use ($reflector) { |
|
117 | + $resolvedTypes = array_map(function(TypeNode $node) use ($reflector) { |
|
118 | 118 | return $this->resolveTypeFromTypeNode($node, $reflector); |
119 | 119 | }, $type->genericTypes); |
120 | 120 | |
121 | - return 'array<' . implode(',', $resolvedTypes) . '>'; |
|
121 | + return 'array<'.implode(',', $resolvedTypes).'>'; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | if ($this->isSimpleType($type->type, 'list')) { |
125 | - $resolvedTypes = array_map(function (TypeNode $node) use ($reflector) { |
|
125 | + $resolvedTypes = array_map(function(TypeNode $node) use ($reflector) { |
|
126 | 126 | return $this->resolveTypeFromTypeNode($node, $reflector); |
127 | 127 | }, $type->genericTypes); |
128 | 128 | |
129 | - return 'array<int, ' . implode(',', $resolvedTypes) . '>'; |
|
129 | + return 'array<int, '.implode(',', $resolvedTypes).'>'; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | throw new \InvalidArgumentException(sprintf("Can't use non-array generic type %s for collection in %s:%s", (string) $type->type, $reflector->getDeclaringClass()->getName(), $reflector->getName())); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | return []; |
150 | 150 | } |
151 | 151 | |
152 | - return array_merge(...array_map(static function ($node) { |
|
152 | + return array_merge(...array_map(static function($node) { |
|
153 | 153 | if ($node->type instanceof UnionTypeNode) { |
154 | 154 | return $node->type->types; |
155 | 155 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | private function filterNullFromTypes(array $types): array |
195 | 195 | { |
196 | - return array_values(array_filter(array_map(function (TypeNode $node) { |
|
196 | + return array_values(array_filter(array_map(function(TypeNode $node) { |
|
197 | 197 | return $this->isNullType($node) ? null : $node; |
198 | 198 | }, $types))); |
199 | 199 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | private function resolveTypeFromTypeNode(TypeNode $typeNode, $reflector): string |
238 | 238 | { |
239 | - if (!($typeNode instanceof IdentifierTypeNode)) { |
|
239 | + if ( ! ($typeNode instanceof IdentifierTypeNode)) { |
|
240 | 240 | throw new \InvalidArgumentException(sprintf("Can't use unsupported type %s for collection in %s:%s", (string) $typeNode, $reflector->getDeclaringClass()->getName(), $reflector->getName())); |
241 | 241 | } |
242 | 242 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | return $typeHint; |
253 | 253 | } |
254 | 254 | |
255 | - $expandedClassName = $declaringClass->getNamespaceName() . '\\' . $typeHint; |
|
255 | + $expandedClassName = $declaringClass->getNamespaceName().'\\'.$typeHint; |
|
256 | 256 | if ($this->isClassOrInterface($expandedClassName)) { |
257 | 257 | return $expandedClassName; |
258 | 258 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | |
287 | 287 | private function endsWith(string $statementClassToCheck, string $typeHintToSearchFor): bool |
288 | 288 | { |
289 | - $typeHintToSearchFor = '\\' . $typeHintToSearchFor; |
|
289 | + $typeHintToSearchFor = '\\'.$typeHintToSearchFor; |
|
290 | 290 | |
291 | 291 | return substr($statementClassToCheck, -strlen($typeHintToSearchFor)) === $typeHintToSearchFor; |
292 | 292 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | preg_match_all(self::GROUP_USE_STATEMENTS_REGEX, $classContents, $foundGroupUseStatements); |
308 | 308 | for ($useStatementIndex = 0; $useStatementIndex < count($foundGroupUseStatements[0]); $useStatementIndex++) { |
309 | 309 | foreach (explode(',', $foundGroupUseStatements[2][$useStatementIndex]) as $singleUseStatement) { |
310 | - $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]) . trim($singleUseStatement); |
|
310 | + $foundUseStatements[] = trim($foundGroupUseStatements[1][$useStatementIndex]).trim($singleUseStatement); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | */ |
347 | 347 | private function resolveType(string $typeHint, $reflector): string |
348 | 348 | { |
349 | - if (!$this->hasGlobalNamespacePrefix($typeHint) && !$this->isPrimitiveType($typeHint)) { |
|
349 | + if ( ! $this->hasGlobalNamespacePrefix($typeHint) && ! $this->isPrimitiveType($typeHint)) { |
|
350 | 350 | $typeHint = $this->expandClassNameUsingUseStatements($typeHint, $this->getDeclaringClassOrTrait($reflector), $reflector); |
351 | 351 | } |
352 | 352 | |
@@ -364,15 +364,15 @@ discard block |
||
364 | 364 | private function resolveTypeFromDocblock($reflector): array |
365 | 365 | { |
366 | 366 | $docComment = $reflector->getDocComment(); |
367 | - if (!$docComment && PHP_VERSION_ID >= 80000 && $reflector instanceof \ReflectionProperty && $reflector->isPromoted()) { |
|
367 | + if ( ! $docComment && PHP_VERSION_ID >= 80000 && $reflector instanceof \ReflectionProperty && $reflector->isPromoted()) { |
|
368 | 368 | $constructor = $reflector->getDeclaringClass()->getConstructor(); |
369 | - if (!$constructor) { |
|
369 | + if ( ! $constructor) { |
|
370 | 370 | return []; |
371 | 371 | } |
372 | 372 | |
373 | 373 | $docComment = $constructor->getDocComment(); |
374 | 374 | |
375 | - if (!$docComment) { |
|
375 | + if ( ! $docComment) { |
|
376 | 376 | return []; |
377 | 377 | } |
378 | 378 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | return $this->flattenParamTagValueTypes($reflector->getName(), $phpDocNode->getParamTagValues()); |
383 | 383 | } |
384 | 384 | |
385 | - if (!$docComment) { |
|
385 | + if ( ! $docComment) { |
|
386 | 386 | return []; |
387 | 387 | } |
388 | 388 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | |
427 | 427 | return sprintf('array<%s>', implode( |
428 | 428 | ',', |
429 | - array_map(static function (string $type) use ($reflector, $self) { |
|
429 | + array_map(static function(string $type) use ($reflector, $self) { |
|
430 | 430 | return $self->resolveType(trim($type), $reflector); |
431 | 431 | }, $types) |
432 | 432 | )); |