@@ -72,7 +72,7 @@ |
||
| 72 | 72 | */ |
| 73 | 73 | private function buildAnnotation(array $attributes): ?SerializerAttribute |
| 74 | 74 | { |
| 75 | - if (!isset($attributes[0])) { |
|
| 75 | + if ( ! isset($attributes[0])) { |
|
| 76 | 76 | return null; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $configured = false; |
| 82 | 82 | |
| 83 | 83 | $classMetadata = new ClassMetadata($name = $class->name); |
| 84 | - $fileResource = $class->getFilename(); |
|
| 84 | + $fileResource = $class->getFilename(); |
|
| 85 | 85 | |
| 86 | 86 | if (false !== $fileResource) { |
| 87 | 87 | $classMetadata->fileResources[] = $fileResource; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if (!$excludeAll) { |
|
| 170 | + if ( ! $excludeAll) { |
|
| 171 | 171 | foreach ($class->getProperties() as $property) { |
| 172 | 172 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
| 173 | 173 | continue; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | } elseif ($annot instanceof Expose) { |
| 202 | 202 | $isExpose = true; |
| 203 | 203 | if (null !== $annot->if) { |
| 204 | - $propertyMetadata->excludeIf = $this->parseExpression('!(' . $annot->if . ')'); |
|
| 204 | + $propertyMetadata->excludeIf = $this->parseExpression('!('.$annot->if.')'); |
|
| 205 | 205 | } |
| 206 | 206 | } elseif ($annot instanceof Exclude) { |
| 207 | 207 | if (null !== $annot->if) { |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | throw new InvalidMetadataException(sprintf( |
| 249 | 249 | 'Invalid group name "%s" on "%s", did you mean to create multiple groups?', |
| 250 | 250 | implode(', ', $propertyMetadata->groups), |
| 251 | - $propertyMetadata->class . '->' . $propertyMetadata->name, |
|
| 251 | + $propertyMetadata->class.'->'.$propertyMetadata->name, |
|
| 252 | 252 | )); |
| 253 | 253 | } |
| 254 | 254 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if (!$propertyMetadata->serializedName) { |
|
| 273 | + if ( ! $propertyMetadata->serializedName) { |
|
| 274 | 274 | $propertyMetadata->serializedName = $this->namingStrategy->translateName($propertyMetadata); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | if ( |
| 284 | - (ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
| 284 | + (ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
| 285 | 285 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
| 286 | 286 | ) { |
| 287 | 287 | $propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]); |
@@ -132,7 +132,7 @@ |
||
| 132 | 132 | |
| 133 | 133 | $accessor = $this->writeAccessors[$metadata->class] ?? null; |
| 134 | 134 | if (null === $accessor) { |
| 135 | - $accessor = \Closure::bind(static function ($o, $name, $value): void { |
|
| 135 | + $accessor = \Closure::bind(static function($o, $name, $value): void { |
|
| 136 | 136 | $o->$name = $value; |
| 137 | 137 | }, null, $metadata->class); |
| 138 | 138 | $this->writeAccessors[$metadata->class] = $accessor; |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | array $type, |
| 45 | 45 | SerializationContext $context |
| 46 | 46 | ) { |
| 47 | - if ((isset($type['params'][1]) && 'value' === $type['params'][1]) || (!isset($type['params'][1]) && $enum instanceof \BackedEnum)) { |
|
| 48 | - if (!$enum instanceof \BackedEnum) { |
|
| 47 | + if ((isset($type['params'][1]) && 'value' === $type['params'][1]) || ( ! isset($type['params'][1]) && $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 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public function createDriver(array $metadataDirs, ?Reader $annotationReader = null): DriverInterface |
| 60 | 60 | { |
| 61 | - if (PHP_VERSION_ID < 80000 && empty($metadataDirs) && !interface_exists(Reader::class)) { |
|
| 61 | + if (PHP_VERSION_ID < 80000 && empty($metadataDirs) && ! interface_exists(Reader::class)) { |
|
| 62 | 62 | throw new RuntimeException(sprintf('To use "%s", either a list of metadata directories must be provided, the "doctrine/annotations" package installed, or use PHP 8.0 or later.', self::class)); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $metadataDrivers[] = new AnnotationOrAttributeDriver($this->propertyNamingStrategy, $this->typeParser, $this->expressionEvaluator, $annotationReader); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if (!empty($metadataDirs)) { |
|
| 79 | + if ( ! empty($metadataDirs)) { |
|
| 80 | 80 | $fileLocator = new FileLocator($metadataDirs); |
| 81 | 81 | |
| 82 | 82 | array_unshift($metadataDrivers, new XmlDriver($fileLocator, $this->propertyNamingStrategy, $this->typeParser, $this->expressionEvaluator)); |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | public function createDriver(array $metadataDirs, ?Reader $reader = null): DriverInterface |
| 28 | 28 | { |
| 29 | 29 | $driver = \call_user_func($this->callback, $metadataDirs, $reader); |
| 30 | - if (!$driver instanceof DriverInterface) { |
|
| 30 | + if ( ! $driver instanceof DriverInterface) { |
|
| 31 | 31 | throw new LogicException('The callback must return an instance of DriverInterface.'); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $this->addExclusionStrategy(new VersionExclusionStrategy($this->attributes['version'])); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (!empty($this->attributes['max_depth_checks'])) { |
|
| 81 | + if ( ! empty($this->attributes['max_depth_checks'])) { |
|
| 82 | 82 | $this->addExclusionStrategy(new DepthExclusionStrategy()); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | final protected function assertMutable(): void |
| 135 | 135 | { |
| 136 | - if (!$this->initialized) { |
|
| 136 | + if ( ! $this->initialized) { |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $metadata = $this->metadataStack->pop(); |
| 224 | 224 | |
| 225 | - if (!$metadata instanceof PropertyMetadata) { |
|
| 225 | + if ( ! $metadata instanceof PropertyMetadata) { |
|
| 226 | 226 | throw new RuntimeException('Context metadataStack not working well'); |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | { |
| 232 | 232 | $metadata = $this->metadataStack->pop(); |
| 233 | 233 | |
| 234 | - if (!$metadata instanceof ClassMetadata) { |
|
| 234 | + if ( ! $metadata instanceof ClassMetadata) { |
|
| 235 | 235 | throw new RuntimeException('Context metadataStack not working well'); |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | public function getCurrentPath(): array |
| 245 | 245 | { |
| 246 | - if (!$this->metadataStack) { |
|
| 246 | + if ( ! $this->metadataStack) { |
|
| 247 | 247 | return []; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | private function reorderTypes(array $types): array |
| 61 | 61 | { |
| 62 | - uasort($types, static function ($a, $b) { |
|
| 62 | + uasort($types, static function($a, $b) { |
|
| 63 | 63 | $order = ['null' => 0, 'true' => 1, 'false' => 2, 'bool' => 3, 'int' => 4, 'float' => 5, 'array' => 6, 'string' => 7]; |
| 64 | 64 | |
| 65 | 65 | return ($order[$a['name']] ?? 8) <=> ($order[$b['name']] ?? 8); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | private function shouldTypeHint(?ReflectionType $reflectionType): bool |
| 161 | 161 | { |
| 162 | - if (!$reflectionType instanceof ReflectionNamedType) { |
|
| 162 | + if ( ! $reflectionType instanceof ReflectionNamedType) { |
|
| 163 | 163 | return false; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | private function shouldTypeHintUnion(?ReflectionType $reflectionType) |
| 178 | 178 | { |
| 179 | - if (!$reflectionType instanceof \ReflectionUnionType) { |
|
| 179 | + if ( ! $reflectionType instanceof \ReflectionUnionType) { |
|
| 180 | 180 | return false; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | case 'bool': |
| 146 | 146 | case 'boolean': |
| 147 | - return !is_array($data) && (string) (bool) $data === (string) $data; |
|
| 147 | + return ! is_array($data) && (string) (bool) $data === (string) $data; |
|
| 148 | 148 | |
| 149 | 149 | case 'true': |
| 150 | 150 | return true === $data; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | return false === $data; |
| 154 | 154 | |
| 155 | 155 | case 'string': |
| 156 | - return !is_array($data) && !is_object($data); |
|
| 156 | + return ! is_array($data) && ! is_object($data); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | return false; |