Completed
Push — master ( b48dc5...46c1ee )
by Marcin
22s queued 19s
created
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 = $metadata->xmlNamespace ?? $this->getClassDefaultNamespace($this->objectMetadataStack->top());
322 322
 
323 323
             $element = $this->createElement($metadata->serializedName, $namespace);
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
     private function isSkippableEmptyObject(?\DOMElement $node, PropertyMetadata $metadata): bool
362 362
     {
363
-        return null === $node && !$metadata->xmlCollection && $metadata->skipWhenEmpty;
363
+        return null === $node && ! $metadata->xmlCollection && $metadata->skipWhenEmpty;
364 364
     }
365 365
 
366 366
     private function isSkippableCollection(PropertyMetadata $metadata): bool
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 
371 371
     private function isElementEmpty(\DOMElement $element): bool
372 372
     {
373
-        return !$element->hasChildNodes() && !$element->hasAttributes();
373
+        return ! $element->hasChildNodes() && ! $element->hasAttributes();
374 374
     }
375 375
 
376 376
     public function endVisitingObject(ClassMetadata $metadata, object $data, array $type): void
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
         foreach ($metadata->xmlNamespaces as $prefix => $uri) {
476 476
             $attribute = 'xmlns';
477 477
             if ('' !== $prefix) {
478
-                $attribute .= ':' . $prefix;
478
+                $attribute .= ':'.$prefix;
479 479
             } elseif ($element->namespaceURI === $uri) {
480 480
                 continue;
481 481
             }
@@ -505,21 +505,21 @@  discard block
 block discarded – undo
505 505
             return $this->document->createElementNS($namespace, $tagName);
506 506
         }
507 507
 
508
-        if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) {
509
-            $prefix = 'ns-' . substr(sha1($namespace), 0, 8);
508
+        if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) {
509
+            $prefix = 'ns-'.substr(sha1($namespace), 0, 8);
510 510
         }
511 511
 
512
-        return $this->document->createElementNS($namespace, $prefix . ':' . $tagName);
512
+        return $this->document->createElementNS($namespace, $prefix.':'.$tagName);
513 513
     }
514 514
 
515 515
     private function setAttributeOnNode(\DOMElement $node, string $name, string $value, ?string $namespace = null): void
516 516
     {
517 517
         if (null !== $namespace) {
518
-            if (!$prefix = $node->lookupPrefix($namespace)) {
519
-                $prefix = 'ns-' . substr(sha1($namespace), 0, 8);
518
+            if ( ! $prefix = $node->lookupPrefix($namespace)) {
519
+                $prefix = 'ns-'.substr(sha1($namespace), 0, 8);
520 520
             }
521 521
 
522
-            $node->setAttributeNS($namespace, $prefix . ':' . $name, $value);
522
+            $node->setAttributeNS($namespace, $prefix.':'.$name, $value);
523 523
         } else {
524 524
             $node->setAttribute($name, $value);
525 525
         }
Please login to merge, or discard this patch.
src/Handler/EnumHandler.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
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
 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/Builder/DefaultDriverFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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));
Please login to merge, or discard this patch.
src/Builder/CallbackDriverFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.