@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | SerializationContext $context |
| 46 | 46 | ) { |
| 47 | 47 | if (isset($type['params'][1]) && 'value' === $type['params'][1]) { |
| 48 | - if (!$enum instanceof \BackedEnum) { |
|
| 48 | + if ( ! $enum instanceof \BackedEnum) { |
|
| 49 | 49 | throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you can not use "value" as serialization mode for its value.', get_class($enum))); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | $caseValue = (string) $data; |
| 68 | 68 | |
| 69 | 69 | $ref = new \ReflectionEnum($enumType); |
| 70 | - if (isset($type['params'][1]) && 'value' === $type['params'][1] || (!isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) { |
|
| 71 | - if (!is_a($enumType, \BackedEnum::class, true)) { |
|
| 70 | + if (isset($type['params'][1]) && 'value' === $type['params'][1] || ( ! isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) { |
|
| 71 | + if ( ! is_a($enumType, \BackedEnum::class, true)) { |
|
| 72 | 72 | throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you can not use "value" as serialization mode for its value.', $enumType)); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if ('int' === $ref->getBackingType()->getName()) { |
| 76 | - if (!is_numeric($caseValue)) { |
|
| 76 | + if ( ! is_numeric($caseValue)) { |
|
| 77 | 77 | throw new RuntimeException(sprintf('"%s" is not a valid backing value for enum "%s"', $caseValue, $enumType)); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | return $enumType::from($caseValue); |
| 84 | 84 | } else { |
| 85 | - if (!$ref->hasCase($caseValue)) { |
|
| 85 | + if ( ! $ref->hasCase($caseValue)) { |
|
| 86 | 86 | throw new InvalidMetadataException(sprintf('The type "%s" does not have the case "%s"', $ref->getName(), $caseValue)); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -81,25 +81,25 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | { |
| 14 | 14 | $type = $event->getType(); |
| 15 | 15 | |
| 16 | - if (isset($type['name']) && ('enum' === $type['name'] || !is_a($type['name'], \UnitEnum::class, true))) { |
|
| 16 | + if (isset($type['name']) && ('enum' === $type['name'] || ! is_a($type['name'], \UnitEnum::class, true))) { |
|
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | 19 | |