@@ -118,7 +118,7 @@ |
||
118 | 118 | $data, |
119 | 119 | array $type |
120 | 120 | ): Generator { |
121 | - return (static function ($visitor, $data, $type): Generator { |
|
121 | + return (static function($visitor, $data, $type): Generator { |
|
122 | 122 | $type['name'] = 'array'; |
123 | 123 | yield from $visitor->visitArray($data, $type); |
124 | 124 | })($visitor, $data, $type); |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function visitArray($data, array $type, GraphNavigatorInterface $navigator): array |
95 | 95 | { |
96 | - if (!\is_array($data)) { |
|
96 | + if ( ! \is_array($data)) { |
|
97 | 97 | throw new RuntimeException(sprintf('Expected array, but got %s: %s', \gettype($data), json_encode($data))); |
98 | 98 | } |
99 | 99 | |
100 | 100 | // If no further parameters were given, keys/values are just passed as is. |
101 | - if (!$type['params']) { |
|
101 | + if ( ! $type['params']) { |
|
102 | 102 | return $data; |
103 | 103 | } |
104 | 104 | |
@@ -165,23 +165,23 @@ discard block |
||
165 | 165 | return; |
166 | 166 | } |
167 | 167 | |
168 | - if (!\is_array($data)) { |
|
168 | + if ( ! \is_array($data)) { |
|
169 | 169 | throw new RuntimeException(sprintf('Invalid data %s (%s), expected "%s".', json_encode($data), $metadata->type['name'], $metadata->class)); |
170 | 170 | } |
171 | 171 | |
172 | 172 | if (true === $metadata->inline) { |
173 | - if (!$metadata->type) { |
|
173 | + if ( ! $metadata->type) { |
|
174 | 174 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
175 | 175 | } |
176 | 176 | |
177 | 177 | return $navigator->accept($data, $metadata->type); |
178 | 178 | } |
179 | 179 | |
180 | - if (!array_key_exists($name, $data)) { |
|
180 | + if ( ! array_key_exists($name, $data)) { |
|
181 | 181 | throw new NotAcceptableException(); |
182 | 182 | } |
183 | 183 | |
184 | - if (!$metadata->type) { |
|
184 | + if ( ! $metadata->type) { |
|
185 | 185 | throw RuntimeException::noMetadataForProperty($metadata->class, $metadata->name); |
186 | 186 | } |
187 | 187 |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | $metadata = $this->metadataFactory->getMetadataForClass($type['name']); |
168 | 168 | \assert($metadata instanceof ClassMetadata); |
169 | 169 | |
170 | - if ($metadata->usingExpression && !$this->expressionExclusionStrategy) { |
|
170 | + if ($metadata->usingExpression && ! $this->expressionExclusionStrategy) { |
|
171 | 171 | throw new ExpressionLanguageRequiredException(sprintf('To use conditional exclude/expose in %s you must configure the expression language.', $metadata->name)); |
172 | 172 | } |
173 | 173 | |
174 | - if (!empty($metadata->discriminatorMap) && $type['name'] === $metadata->discriminatorBaseClass) { |
|
174 | + if ( ! empty($metadata->discriminatorMap) && $type['name'] === $metadata->discriminatorBaseClass) { |
|
175 | 175 | $metadata = $this->resolveMetadata($data, $metadata); |
176 | 176 | } |
177 | 177 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | $typeValue = $this->context->getVisitor()->visitDiscriminatorMapProperty($data, $metadata); |
235 | 235 | |
236 | - if (!isset($metadata->discriminatorMap[$typeValue])) { |
|
236 | + if ( ! isset($metadata->discriminatorMap[$typeValue])) { |
|
237 | 237 | throw new LogicException(sprintf( |
238 | 238 | 'The type value "%s" does not exist in the discriminator map of class "%s". Available types: %s', |
239 | 239 | $typeValue, |
@@ -104,7 +104,7 @@ discard block |
||
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 |
||
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 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $node = $navigator->accept($v, $metadata->type); |
253 | 253 | $this->revertCurrentMetadata(); |
254 | 254 | |
255 | - if (!$node instanceof \DOMCharacterData) { |
|
255 | + if ( ! $node instanceof \DOMCharacterData) { |
|
256 | 256 | throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v))); |
257 | 257 | } |
258 | 258 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | |
264 | 264 | if ( |
265 | 265 | ($metadata->xmlValue && $this->currentNode->childNodes->length > 0) |
266 | - || (!$metadata->xmlValue && $this->hasValue) |
|
266 | + || ( ! $metadata->xmlValue && $this->hasValue) |
|
267 | 267 | ) { |
268 | 268 | 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)); |
269 | 269 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $node = $navigator->accept($v, $metadata->type); |
276 | 276 | $this->revertCurrentMetadata(); |
277 | 277 | |
278 | - if (!$node instanceof \DOMCharacterData) { |
|
278 | + if ( ! $node instanceof \DOMCharacterData) { |
|
279 | 279 | throw new RuntimeException(sprintf('Unsupported value for property %s::$%s. Expected character data, but got %s.', $metadata->reflection->class, $metadata->reflection->name, \is_object($node) ? \get_class($node) : \gettype($node))); |
280 | 280 | } |
281 | 281 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | if ($metadata->xmlAttributeMap) { |
288 | - if (!\is_array($v)) { |
|
288 | + if ( ! \is_array($v)) { |
|
289 | 289 | throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', \gettype($v))); |
290 | 290 | } |
291 | 291 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $node = $navigator->accept($value, null); |
295 | 295 | $this->revertCurrentMetadata(); |
296 | 296 | |
297 | - if (!$node instanceof \DOMCharacterData) { |
|
297 | + if ( ! $node instanceof \DOMCharacterData) { |
|
298 | 298 | throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v))); |
299 | 299 | } |
300 | 300 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | return; |
305 | 305 | } |
306 | 306 | |
307 | - if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { |
|
307 | + if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) { |
|
308 | 308 | $namespace = null !== $metadata->xmlNamespace |
309 | 309 | ? $metadata->xmlNamespace |
310 | 310 | : $this->getClassDefaultNamespace($this->objectMetadataStack->top()); |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | private function isSkippableEmptyObject(?\DOMElement $node, PropertyMetadata $metadata): bool |
351 | 351 | { |
352 | - return null === $node && !$metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
352 | + return null === $node && ! $metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | private function isSkippableCollection(PropertyMetadata $metadata): bool |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | private function isElementEmpty(\DOMElement $element): bool |
361 | 361 | { |
362 | - return !$element->hasChildNodes() && !$element->hasAttributes(); |
|
362 | + return ! $element->hasChildNodes() && ! $element->hasAttributes(); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | public function endVisitingObject(ClassMetadata $metadata, object $data, array $type): void |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | foreach ($metadata->xmlNamespaces as $prefix => $uri) { |
464 | 464 | $attribute = 'xmlns'; |
465 | 465 | if ('' !== $prefix) { |
466 | - $attribute .= ':' . $prefix; |
|
466 | + $attribute .= ':'.$prefix; |
|
467 | 467 | } elseif ($element->namespaceURI === $uri) { |
468 | 468 | continue; |
469 | 469 | } |
@@ -493,21 +493,21 @@ discard block |
||
493 | 493 | return $this->document->createElementNS($namespace, $tagName); |
494 | 494 | } |
495 | 495 | |
496 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
497 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
496 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
497 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
498 | 498 | } |
499 | 499 | |
500 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
500 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | private function setAttributeOnNode(\DOMElement $node, string $name, string $value, ?string $namespace = null): void |
504 | 504 | { |
505 | 505 | if (null !== $namespace) { |
506 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
507 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
506 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
507 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
508 | 508 | } |
509 | 509 | |
510 | - $node->setAttributeNS($namespace, $prefix . ':' . $name, $value); |
|
510 | + $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
|
511 | 511 | } else { |
512 | 512 | $node->setAttribute($name, $value); |
513 | 513 | } |