Passed
Pull Request — master (#1497)
by Asmir
06:08 queued 03:25
created
src/Metadata/Driver/EnumPropertiesDriver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
     {
75 75
         $reflectionType = $propertyReflection->getType();
76 76
 
77
-        if (!($reflectionType instanceof \ReflectionNamedType)) {
77
+        if ( ! ($reflectionType instanceof \ReflectionNamedType)) {
78 78
             return null;
79 79
         }
80 80
 
Please login to merge, or discard this patch.
src/Handler/EnumHandler.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/EventDispatcher/Subscriber/EnumSubscriber.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/JsonSerializationVisitor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     public function visitDouble(float $data, array $type)
72 72
     {
73 73
         $precision = $type['params'][0] ?? null;
74
-        if (!is_int($precision)) {
74
+        if ( ! is_int($precision)) {
75 75
             return $data;
76 76
         }
77 77
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
         $rs = isset($type['params'][1]) ? new \ArrayObject() : [];
95 95
 
96
-        $isList = isset($type['params'][0]) && !isset($type['params'][1]);
96
+        $isList = isset($type['params'][0]) && ! isset($type['params'][1]);
97 97
 
98 98
         $elType = $this->getElementType($type);
99 99
         foreach ($data as $k => $v) {
Please login to merge, or discard this patch.
src/XmlSerializationVisitor.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
     public function createRoot(?ClassMetadata $metadata = null, ?string $rootName = null, ?string $rootNamespace = null, ?string $rootPrefix = null): \DOMElement
106 106
     {
107
-        if (null !== $metadata && !empty($metadata->xmlRootName)) {
107
+        if (null !== $metadata && ! empty($metadata->xmlRootName)) {
108 108
             $rootPrefix = $metadata->xmlRootPrefix;
109 109
             $rootName = $metadata->xmlRootName;
110 110
             $rootNamespace = $metadata->xmlRootNamespace ?: $this->getClassDefaultNamespace($metadata);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
         $document = $this->getDocument();
118 118
         if ($rootNamespace) {
119
-            $rootNode = $document->createElementNS($rootNamespace, (null !== $rootPrefix ? $rootPrefix . ':' : '') . $rootName);
119
+            $rootNode = $document->createElementNS($rootNamespace, (null !== $rootPrefix ? $rootPrefix.':' : '').$rootName);
120 120
         } else {
121 121
             $rootNode = $document->createElement($rootName);
122 122
         }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         $decimalsNumbers = $type['params'][2] ?? null;
191 191
         if (null === $decimalsNumbers) {
192 192
             $parts = explode('.', (string) $dataResult);
193
-            if (count($parts) < 2 || !$parts[1]) {
193
+            if (count($parts) < 2 || ! $parts[1]) {
194 194
                 $decimalsNumbers = 1;
195 195
             }
196 196
         }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             $node = $this->navigator->accept($v, $metadata->type);
266 266
             $this->revertCurrentMetadata();
267 267
 
268
-            if (!$node instanceof \DOMCharacterData) {
268
+            if ( ! $node instanceof \DOMCharacterData) {
269 269
                 throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v)));
270 270
             }
271 271
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
         if (
278 278
             ($metadata->xmlValue && $this->currentNode->childNodes->length > 0)
279
-            || (!$metadata->xmlValue && $this->hasValue)
279
+            || ( ! $metadata->xmlValue && $this->hasValue)
280 280
         ) {
281 281
             throw new RuntimeException(sprintf('If you make use of @XmlValue, all other properties in the class must have the @XmlAttribute annotation. Invalid usage detected in class %s.', $metadata->class));
282 282
         }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
             $node = $this->navigator->accept($v, $metadata->type);
289 289
             $this->revertCurrentMetadata();
290 290
 
291
-            if (!$node instanceof \DOMCharacterData) {
291
+            if ( ! $node instanceof \DOMCharacterData) {
292 292
                 throw new RuntimeException(sprintf('Unsupported value for property %s::$%s. Expected character data, but got %s.', $metadata->class, $metadata->name, \is_object($node) ? \get_class($node) : \gettype($node)));
293 293
             }
294 294
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         }
299 299
 
300 300
         if ($metadata->xmlAttributeMap) {
301
-            if (!\is_array($v)) {
301
+            if ( ! \is_array($v)) {
302 302
                 throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', \gettype($v)));
303 303
             }
304 304
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
                 $node = $this->navigator->accept($value, null);
308 308
                 $this->revertCurrentMetadata();
309 309
 
310
-                if (!$node instanceof \DOMCharacterData) {
310
+                if ( ! $node instanceof \DOMCharacterData) {
311 311
                     throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v)));
312 312
                 }
313 313
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
             return;
318 318
         }
319 319
 
320
-        if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) {
320
+        if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) {
321 321
             $namespace = null !== $metadata->xmlNamespace
322 322
                 ? $metadata->xmlNamespace
323 323
                 : $this->getClassDefaultNamespace($this->objectMetadataStack->top());
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 
363 363
     private function isSkippableEmptyObject(?\DOMElement $node, PropertyMetadata $metadata): bool
364 364
     {
365
-        return null === $node && !$metadata->xmlCollection && $metadata->skipWhenEmpty;
365
+        return null === $node && ! $metadata->xmlCollection && $metadata->skipWhenEmpty;
366 366
     }
367 367
 
368 368
     private function isSkippableCollection(PropertyMetadata $metadata): bool
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 
373 373
     private function isElementEmpty(\DOMElement $element): bool
374 374
     {
375
-        return !$element->hasChildNodes() && !$element->hasAttributes();
375
+        return ! $element->hasChildNodes() && ! $element->hasAttributes();
376 376
     }
377 377
 
378 378
     public function endVisitingObject(ClassMetadata $metadata, object $data, array $type): void
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
         foreach ($metadata->xmlNamespaces as $prefix => $uri) {
477 477
             $attribute = 'xmlns';
478 478
             if ('' !== $prefix) {
479
-                $attribute .= ':' . $prefix;
479
+                $attribute .= ':'.$prefix;
480 480
             } elseif ($element->namespaceURI === $uri) {
481 481
                 continue;
482 482
             }
@@ -506,21 +506,21 @@  discard block
 block discarded – undo
506 506
             return $this->document->createElementNS($namespace, $tagName);
507 507
         }
508 508
 
509
-        if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) {
510
-            $prefix = 'ns-' . substr(sha1($namespace), 0, 8);
509
+        if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) {
510
+            $prefix = 'ns-'.substr(sha1($namespace), 0, 8);
511 511
         }
512 512
 
513
-        return $this->document->createElementNS($namespace, $prefix . ':' . $tagName);
513
+        return $this->document->createElementNS($namespace, $prefix.':'.$tagName);
514 514
     }
515 515
 
516 516
     private function setAttributeOnNode(\DOMElement $node, string $name, string $value, ?string $namespace = null): void
517 517
     {
518 518
         if (null !== $namespace) {
519
-            if (!$prefix = $node->lookupPrefix($namespace)) {
520
-                $prefix = 'ns-' . substr(sha1($namespace), 0, 8);
519
+            if ( ! $prefix = $node->lookupPrefix($namespace)) {
520
+                $prefix = 'ns-'.substr(sha1($namespace), 0, 8);
521 521
             }
522 522
 
523
-            $node->setAttributeNS($namespace, $prefix . ':' . $name, $value);
523
+            $node->setAttributeNS($namespace, $prefix.':'.$name, $value);
524 524
         } else {
525 525
             $node->setAttribute($name, $value);
526 526
         }
Please login to merge, or discard this patch.
src/Construction/DoctrineObjectConstructor.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $objectManager = $this->managerRegistry->getManagerForClass($metadata->name);
70 70
 
71
-        if (!$objectManager) {
71
+        if ( ! $objectManager) {
72 72
             // No ObjectManager found, proceed with normal deserialization
73 73
             return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
74 74
         }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         }
83 83
 
84 84
         // Managed entity, check for proxy load
85
-        if (!is_array($data) && !(is_object($data) && 'SimpleXMLElement' === get_class($data))) {
85
+        if ( ! is_array($data) && ! (is_object($data) && 'SimpleXMLElement' === get_class($data))) {
86 86
             \assert($objectManager instanceof EntityManagerInterface || $objectManager instanceof DocumentManagerInterface);
87 87
 
88 88
             // Single identifier, load proxy
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         foreach ($classMetadata->getIdentifierFieldNames() as $name) {
97 97
             // Avoid calling objectManager->find if some identification properties are excluded
98
-            if (!isset($metadata->propertyMetadata[$name])) {
98
+            if ( ! isset($metadata->propertyMetadata[$name])) {
99 99
                 return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
100 100
             }
101 101
 
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
                 return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
107 107
             }
108 108
 
109
-            if (is_array($data) && !array_key_exists($propertyMetadata->serializedName, $data)) {
109
+            if (is_array($data) && ! array_key_exists($propertyMetadata->serializedName, $data)) {
110 110
                 return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
111
-            } elseif (is_object($data) && !property_exists($data, $propertyMetadata->serializedName)) {
111
+            } elseif (is_object($data) && ! property_exists($data, $propertyMetadata->serializedName)) {
112 112
                 return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
113 113
             }
114 114
 
Please login to merge, or discard this patch.
src/XmlDeserializationVisitor.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Metadata/Driver/AttributeDriver.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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()
Please login to merge, or discard this patch.
src/Metadata/Driver/TypedPropertiesDriver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.