@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | { |
22 | 22 | assert($doctrineMetadata instanceof ORMClassMetadata || $doctrineMetadata instanceof ODMClassMetadata); |
23 | 23 | if ( |
24 | - empty($classMetadata->discriminatorMap) && !$classMetadata->discriminatorDisabled |
|
25 | - && !empty($doctrineMetadata->discriminatorMap) && $doctrineMetadata->isRootEntity() |
|
24 | + empty($classMetadata->discriminatorMap) && ! $classMetadata->discriminatorDisabled |
|
25 | + && ! empty($doctrineMetadata->discriminatorMap) && $doctrineMetadata->isRootEntity() |
|
26 | 26 | ) { |
27 | 27 | if ($doctrineMetadata->discriminatorColumn instanceof DiscriminatorColumnMapping) { |
28 | 28 | // Doctrine 3.1+ |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | // For inheritance schemes, we cannot add any type as we would only add the super-type of the hierarchy. |
60 | 60 | // On serialization, this would lead to only the supertype being serialized, and properties of subtypes |
61 | 61 | // being ignored. |
62 | - if ($targetMetadata instanceof ODMClassMetadata && !$targetMetadata->isInheritanceTypeNone()) { |
|
62 | + if ($targetMetadata instanceof ODMClassMetadata && ! $targetMetadata->isInheritanceTypeNone()) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | - if (!$doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
66 | + if ( ! $doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
67 | 67 | $targetEntity = sprintf('ArrayCollection<%s>', $targetEntity); |
68 | 68 | } |
69 | 69 |
@@ -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 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $attributes = $data->attributes($metadata->xmlNamespace); |
333 | 333 | |
334 | 334 | if (isset($attributes[$attributeName])) { |
335 | - if (!$metadata->type) { |
|
335 | + if ( ! $metadata->type) { |
|
336 | 336 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
337 | 337 | } |
338 | 338 | |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | $childDataNode = null; |
349 | 349 | if ('' === $metadata->xmlNamespace) { |
350 | 350 | // Element explicitly in NO namespace |
351 | - $xpathQuery = "./*[local-name()='" . $elementName . "' and (namespace-uri()='' or not(namespace-uri()))]"; |
|
351 | + $xpathQuery = "./*[local-name()='".$elementName."' and (namespace-uri()='' or not(namespace-uri()))]"; |
|
352 | 352 | $matchingNodes = $data->xpath($xpathQuery); |
353 | - if (!empty($matchingNodes)) { |
|
353 | + if ( ! empty($matchingNodes)) { |
|
354 | 354 | $childDataNode = $matchingNodes[0]; |
355 | 355 | } |
356 | 356 | } elseif ($metadata->xmlNamespace) { |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | - if (!$childDataNode || !$childDataNode->getName()) { |
|
370 | + if ( ! $childDataNode || ! $childDataNode->getName()) { |
|
371 | 371 | if (null === $metadata->xmlNamespace) { |
372 | 372 | $ns = '[default/none]'; |
373 | 373 | } else { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | $attributes = $childDataNode->attributes($attributeTargetNs); |
382 | 382 | |
383 | 383 | if (isset($attributes[$attributeName])) { |
384 | - if (!$metadata->type) { |
|
384 | + if ( ! $metadata->type) { |
|
385 | 385 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
386 | 386 | } |
387 | 387 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | } |
393 | 393 | |
394 | 394 | if ($metadata->xmlValue) { |
395 | - if (!$metadata->type) { |
|
395 | + if ( ! $metadata->type) { |
|
396 | 396 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
397 | 397 | } |
398 | 398 | |
@@ -401,12 +401,12 @@ discard block |
||
401 | 401 | |
402 | 402 | if ($metadata->xmlCollection) { |
403 | 403 | $enclosingElem = $data; |
404 | - if (!$metadata->xmlCollectionInline) { |
|
404 | + if ( ! $metadata->xmlCollectionInline) { |
|
405 | 405 | $enclosingElem = $data->children($metadata->xmlNamespace)->$name; |
406 | 406 | } |
407 | 407 | |
408 | 408 | $this->setCurrentMetadata($metadata); |
409 | - if (!$metadata->type) { |
|
409 | + if ( ! $metadata->type) { |
|
410 | 410 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
411 | 411 | } |
412 | 412 | |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | |
419 | 419 | if ($metadata->xmlNamespace) { |
420 | 420 | $node = $data->children($metadata->xmlNamespace)->$name; |
421 | - if (!$node->count()) { |
|
421 | + if ( ! $node->count()) { |
|
422 | 422 | throw new NotAcceptableException(); |
423 | 423 | } |
424 | 424 | } elseif ('' === $metadata->xmlNamespace) { |
425 | 425 | // See #1087 - element must be like: <element xmlns="" /> - https://www.w3.org/TR/REC-xml-names/#iri-use |
426 | 426 | // Use of an empty string in a namespace declaration turns it into an "undeclaration". |
427 | - $nodes = $data->xpath('./' . $name); |
|
427 | + $nodes = $data->xpath('./'.$name); |
|
428 | 428 | if (empty($nodes)) { |
429 | 429 | throw new NotAcceptableException(); |
430 | 430 | } |
@@ -435,9 +435,9 @@ discard block |
||
435 | 435 | if (isset($namespaces[''])) { |
436 | 436 | $prefix = uniqid('ns-'); |
437 | 437 | $data->registerXPathNamespace($prefix, $namespaces['']); |
438 | - $nodes = $data->xpath('./' . $prefix . ':' . $name); |
|
438 | + $nodes = $data->xpath('./'.$prefix.':'.$name); |
|
439 | 439 | } else { |
440 | - $nodes = $data->xpath('./' . $name); |
|
440 | + $nodes = $data->xpath('./'.$name); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | if (empty($nodes)) { |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | $this->setCurrentMetadata($metadata); |
452 | 452 | } |
453 | 453 | |
454 | - if (!$metadata->type) { |
|
454 | + if ( ! $metadata->type) { |
|
455 | 455 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
456 | 456 | } |
457 | 457 |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | public function createRoot(?ClassMetadata $metadata = null, ?string $rootName = null, ?string $rootNamespace = null, ?string $rootPrefix = null): \DOMElement |
107 | 107 | { |
108 | - if (null !== $metadata && !empty($metadata->xmlRootName)) { |
|
108 | + if (null !== $metadata && ! empty($metadata->xmlRootName)) { |
|
109 | 109 | $rootPrefix = $metadata->xmlRootPrefix; |
110 | 110 | $rootName = $metadata->xmlRootName; |
111 | 111 | $rootNamespace = $metadata->xmlRootNamespace ?: $this->getClassDefaultNamespace($metadata); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | $document = $this->getDocument(); |
119 | 119 | if ($rootNamespace) { |
120 | - $rootNode = $document->createElementNS($rootNamespace, (null !== $rootPrefix ? $rootPrefix . ':' : '') . $rootName); |
|
120 | + $rootNode = $document->createElementNS($rootNamespace, (null !== $rootPrefix ? $rootPrefix.':' : '').$rootName); |
|
121 | 121 | } else { |
122 | 122 | $rootNode = $document->createElement($rootName); |
123 | 123 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $decimalsNumbers = $type['params'][2] ?? null; |
192 | 192 | if (null === $decimalsNumbers) { |
193 | 193 | $parts = explode('.', (string) $dataResult); |
194 | - if (count($parts) < 2 || !$parts[1]) { |
|
194 | + if (count($parts) < 2 || ! $parts[1]) { |
|
195 | 195 | $decimalsNumbers = 1; |
196 | 196 | } |
197 | 197 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $node = $this->navigator->accept($v, $metadata->type); |
267 | 267 | $this->revertCurrentMetadata(); |
268 | 268 | |
269 | - if (!$node instanceof \DOMCharacterData) { |
|
269 | + if ( ! $node instanceof \DOMCharacterData) { |
|
270 | 270 | throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v))); |
271 | 271 | } |
272 | 272 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | if ( |
279 | 279 | ($metadata->xmlValue && $this->currentNode->childNodes->length > 0) |
280 | - || (!$metadata->xmlValue && $this->hasValue) |
|
280 | + || ( ! $metadata->xmlValue && $this->hasValue) |
|
281 | 281 | ) { |
282 | 282 | 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)); |
283 | 283 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $node = $this->navigator->accept($v, $metadata->type); |
290 | 290 | $this->revertCurrentMetadata(); |
291 | 291 | |
292 | - if (!$node instanceof \DOMCharacterData) { |
|
292 | + if ( ! $node instanceof \DOMCharacterData) { |
|
293 | 293 | 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))); |
294 | 294 | } |
295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | if ($metadata->xmlAttributeMap) { |
302 | - if (!\is_array($v)) { |
|
302 | + if ( ! \is_array($v)) { |
|
303 | 303 | throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', \gettype($v))); |
304 | 304 | } |
305 | 305 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $node = $this->navigator->accept($value, null); |
309 | 309 | $this->revertCurrentMetadata(); |
310 | 310 | |
311 | - if (!$node instanceof \DOMCharacterData) { |
|
311 | + if ( ! $node instanceof \DOMCharacterData) { |
|
312 | 312 | throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v))); |
313 | 313 | } |
314 | 314 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | return; |
341 | 341 | } |
342 | 342 | |
343 | - if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { |
|
343 | + if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) { |
|
344 | 344 | $namespace = $metadata->xmlNamespace ?? $this->getClassDefaultNamespace($this->objectMetadataStack->top()); |
345 | 345 | |
346 | 346 | $element = $this->createElement($metadata->serializedName, $namespace); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | - if (!$targetElement) { |
|
405 | + if ( ! $targetElement) { |
|
406 | 406 | return false; |
407 | 407 | } |
408 | 408 | |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | |
453 | 453 | private function isSkippableEmptyObject(?\DOMElement $node, PropertyMetadata $metadata): bool |
454 | 454 | { |
455 | - return null === $node && !$metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
455 | + return null === $node && ! $metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | private function isSkippableCollection(PropertyMetadata $metadata): bool |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | |
463 | 463 | private function isElementEmpty(\DOMElement $element): bool |
464 | 464 | { |
465 | - return !$element->hasChildNodes() && !$element->hasAttributes(); |
|
465 | + return ! $element->hasChildNodes() && ! $element->hasAttributes(); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | public function endVisitingObject(ClassMetadata $metadata, object $data, array $type): void |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | foreach ($metadata->xmlNamespaces as $prefix => $uri) { |
568 | 568 | $attribute = 'xmlns'; |
569 | 569 | if ('' !== $prefix) { |
570 | - $attribute .= ':' . $prefix; |
|
570 | + $attribute .= ':'.$prefix; |
|
571 | 571 | } elseif ($element->namespaceURI === $uri) { |
572 | 572 | continue; |
573 | 573 | } |
@@ -597,21 +597,21 @@ discard block |
||
597 | 597 | return $this->document->createElementNS($namespace, $tagName); |
598 | 598 | } |
599 | 599 | |
600 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
601 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
600 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
601 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
602 | 602 | } |
603 | 603 | |
604 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
604 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | private function setAttributeOnNode(\DOMElement $node, string $name, string $value, ?string $namespace = null): void |
608 | 608 | { |
609 | 609 | if (null !== $namespace) { |
610 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
611 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
610 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
611 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
612 | 612 | } |
613 | 613 | |
614 | - $node->setAttributeNS($namespace, $prefix . ':' . $name, $value); |
|
614 | + $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
|
615 | 615 | } else { |
616 | 616 | $node->setAttribute($name, $value); |
617 | 617 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | private function getNavigator(int $direction): GraphNavigatorInterface |
117 | 117 | { |
118 | - if (!isset($this->graphNavigators[$direction])) { |
|
118 | + if ( ! isset($this->graphNavigators[$direction])) { |
|
119 | 119 | throw new RuntimeException( |
120 | 120 | sprintf( |
121 | 121 | 'Cannot find a graph navigator for the direction "%s".', |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ? $this->serializationVisitors |
134 | 134 | : $this->deserializationVisitors; |
135 | 135 | |
136 | - if (!isset($factories[$format])) { |
|
136 | + if ( ! isset($factories[$format])) { |
|
137 | 137 | throw new UnsupportedFormatException( |
138 | 138 | sprintf( |
139 | 139 | 'The format "%s" is not supported for %s.', |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $result = $this->visit($navigator, $visitor, $context, $data, 'json', $type); |
203 | 203 | $result = $this->convertArrayObjects($result); |
204 | 204 | |
205 | - if (!\is_array($result)) { |
|
205 | + if ( ! \is_array($result)) { |
|
206 | 206 | throw new RuntimeException(sprintf( |
207 | 207 | 'The input data of type "%s" did not convert to an array, but got a result of type "%s".', |
208 | 208 | \is_object($data) ? \get_class($data) : \gettype($data), |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | array $type, |
52 | 52 | SerializationContext $context |
53 | 53 | ) { |
54 | - if ((isset($type['params'][1]) && 'value' === $type['params'][1]) || (!isset($type['params'][1]) && $enum instanceof \BackedEnum)) { |
|
55 | - if (!$enum instanceof \BackedEnum) { |
|
54 | + if ((isset($type['params'][1]) && 'value' === $type['params'][1]) || ( ! isset($type['params'][1]) && $enum instanceof \BackedEnum)) { |
|
55 | + if ( ! $enum instanceof \BackedEnum) { |
|
56 | 56 | throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you cannot use "value" as serialization mode for its value.', get_class($enum))); |
57 | 57 | } |
58 | 58 | |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | $caseValue = (string) $data; |
81 | 81 | |
82 | 82 | $ref = new \ReflectionEnum($enumType); |
83 | - if (isset($type['params'][1]) && 'value' === $type['params'][1] || (!isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) { |
|
84 | - if (!is_a($enumType, \BackedEnum::class, true)) { |
|
83 | + if (isset($type['params'][1]) && 'value' === $type['params'][1] || ( ! isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) { |
|
84 | + if ( ! is_a($enumType, \BackedEnum::class, true)) { |
|
85 | 85 | throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you cannot use "value" as serialization mode for its value.', $enumType)); |
86 | 86 | } |
87 | 87 | |
88 | 88 | if ('int' === $ref->getBackingType()->getName()) { |
89 | - if (!is_numeric($caseValue)) { |
|
89 | + if ( ! is_numeric($caseValue)) { |
|
90 | 90 | throw new RuntimeException(sprintf('"%s" is not a valid backing value for enum "%s"', $caseValue, $enumType)); |
91 | 91 | } |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | return $enumType::from($caseValue); |
97 | 97 | } else { |
98 | - if (!$ref->hasCase($caseValue)) { |
|
98 | + if ( ! $ref->hasCase($caseValue)) { |
|
99 | 99 | throw new InvalidMetadataException(sprintf('The type "%s" does not have the case "%s"', $ref->getName(), $caseValue)); |
100 | 100 | } |
101 | 101 |