@@ -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 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $node = $this->navigator->accept($v, $metadata->type); |
243 | 243 | $this->revertCurrentMetadata(); |
244 | 244 | |
245 | - if (!$node instanceof \DOMCharacterData) { |
|
245 | + if ( ! $node instanceof \DOMCharacterData) { |
|
246 | 246 | throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v))); |
247 | 247 | } |
248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | if (($metadata->xmlValue && $this->currentNode->childNodes->length > 0) |
255 | - || (!$metadata->xmlValue && $this->hasValue) |
|
255 | + || ( ! $metadata->xmlValue && $this->hasValue) |
|
256 | 256 | ) { |
257 | 257 | 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)); |
258 | 258 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $node = $this->navigator->accept($v, $metadata->type); |
265 | 265 | $this->revertCurrentMetadata(); |
266 | 266 | |
267 | - if (!$node instanceof \DOMCharacterData) { |
|
267 | + if ( ! $node instanceof \DOMCharacterData) { |
|
268 | 268 | 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))); |
269 | 269 | } |
270 | 270 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | if ($metadata->xmlAttributeMap) { |
277 | - if (!\is_array($v)) { |
|
277 | + if ( ! \is_array($v)) { |
|
278 | 278 | throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', \gettype($v))); |
279 | 279 | } |
280 | 280 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $node = $this->navigator->accept($value, null); |
284 | 284 | $this->revertCurrentMetadata(); |
285 | 285 | |
286 | - if (!$node instanceof \DOMCharacterData) { |
|
286 | + if ( ! $node instanceof \DOMCharacterData) { |
|
287 | 287 | throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v))); |
288 | 288 | } |
289 | 289 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
296 | - if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { |
|
296 | + if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) { |
|
297 | 297 | $namespace = null !== $metadata->xmlNamespace |
298 | 298 | ? $metadata->xmlNamespace |
299 | 299 | : $this->getClassDefaultNamespace($this->objectMetadataStack->top()); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | |
338 | 338 | private function isSkippableEmptyObject(?\DOMElement $node, PropertyMetadata $metadata): bool |
339 | 339 | { |
340 | - return null === $node && !$metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
340 | + return null === $node && ! $metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | private function isSkippableCollection(PropertyMetadata $metadata): bool |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | |
348 | 348 | private function isElementEmpty(\DOMElement $element): bool |
349 | 349 | { |
350 | - return !$element->hasChildNodes() && !$element->hasAttributes(); |
|
350 | + return ! $element->hasChildNodes() && ! $element->hasAttributes(); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | public function endVisitingObject(ClassMetadata $metadata, object $data, array $type): void |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | foreach ($metadata->xmlNamespaces as $prefix => $uri) { |
454 | 454 | $attribute = 'xmlns'; |
455 | 455 | if ('' !== $prefix) { |
456 | - $attribute .= ':' . $prefix; |
|
456 | + $attribute .= ':'.$prefix; |
|
457 | 457 | } elseif ($element->namespaceURI === $uri) { |
458 | 458 | continue; |
459 | 459 | } |
@@ -478,19 +478,19 @@ discard block |
||
478 | 478 | if ($this->currentNode->isDefaultNamespace($namespace)) { |
479 | 479 | return $this->document->createElementNS($namespace, $tagName); |
480 | 480 | } |
481 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
482 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
481 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
482 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
483 | 483 | } |
484 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
484 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | private function setAttributeOnNode(\DOMElement $node, string $name, string $value, ?string $namespace = null): void |
488 | 488 | { |
489 | 489 | if (null !== $namespace) { |
490 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
491 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
490 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
491 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
492 | 492 | } |
493 | - $node->setAttributeNS($namespace, $prefix . ':' . $name, $value); |
|
493 | + $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
|
494 | 494 | } else { |
495 | 495 | $node->setAttribute($name, $value); |
496 | 496 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getAllClassNames(): array |
72 | 72 | { |
73 | - if (!$this->locator instanceof AdvancedFileLocatorInterface) { |
|
73 | + if ( ! $this->locator instanceof AdvancedFileLocatorInterface) { |
|
74 | 74 | throw new RuntimeException( |
75 | 75 | sprintf( |
76 | 76 | 'Locator "%s" must be an instance of "AdvancedFileLocatorInterface".', |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | { |
94 | 94 | $config = Yaml::parse(file_get_contents($file)); |
95 | 95 | |
96 | - if (!isset($config[$name = $class->name])) { |
|
96 | + if ( ! isset($config[$name = $class->name])) { |
|
97 | 97 | throw new InvalidMetadataException( |
98 | 98 | sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file) |
99 | 99 | ); |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | ); |
126 | 126 | unset($propertySettings['exp']); |
127 | 127 | } else { |
128 | - if (!$class->hasMethod($methodName)) { |
|
128 | + if ( ! $class->hasMethod($methodName)) { |
|
129 | 129 | throw new InvalidMetadataException( |
130 | - 'The method ' . $methodName . ' not found in class ' . $class->name |
|
130 | + 'The method '.$methodName.' not found in class '.$class->name |
|
131 | 131 | ); |
132 | 132 | } |
133 | 133 | $virtualPropertyMetadata = new VirtualPropertyMetadata($name, $methodName); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - if (!$excludeAll) { |
|
141 | + if ( ! $excludeAll) { |
|
142 | 142 | foreach ($class->getProperties() as $property) { |
143 | 143 | $fromParent = false; |
144 | 144 | $pName = $property->getName(); |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | $fromParent = true; |
149 | 149 | } |
150 | 150 | |
151 | - if (!$fromParent && $property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
|
151 | + if ( ! $fromParent && $property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
|
152 | 152 | continue; |
153 | 153 | } |
154 | 154 | |
155 | 155 | $pName = $property->getName(); |
156 | 156 | $propertiesMetadata[] = new PropertyMetadata($name, $pName); |
157 | - $propertiesData[] = !empty($config['properties']) && true === array_key_exists($pName, $config['properties']) |
|
157 | + $propertiesData[] = ! empty($config['properties']) && true === array_key_exists($pName, $config['properties']) |
|
158 | 158 | ? (array) $config['properties'][$pName] |
159 | 159 | : null; |
160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | || isset($propertiesData[$propertyKey]); |
167 | 167 | |
168 | 168 | $pConfig = $propertiesData[$propertyKey]; |
169 | - if (!empty($pConfig)) { |
|
169 | + if ( ! empty($pConfig)) { |
|
170 | 170 | if (isset($pConfig['exclude'])) { |
171 | 171 | $isExclude = (bool) $pConfig['exclude']; |
172 | 172 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | |
198 | 198 | if (isset($pConfig['expose_if'])) { |
199 | - $pMetadata->excludeIf = $this->parseExpression('!(' . $pConfig['expose_if'] . ')'); |
|
199 | + $pMetadata->excludeIf = $this->parseExpression('!('.$pConfig['expose_if'].')'); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | if (isset($pConfig['serialized_name'])) { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | - if (!$pMetadata->serializedName) { |
|
307 | + if ( ! $pMetadata->serializedName) { |
|
308 | 308 | $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata); |
309 | 309 | } |
310 | 310 | |
@@ -313,11 +313,11 @@ discard block |
||
313 | 313 | $metadata->isMap = $metadata->isMap || PropertyMetadata::isCollectionMap($pMetadata->type); |
314 | 314 | } |
315 | 315 | |
316 | - if (!empty($pConfig) && !empty($pConfig['name'])) { |
|
316 | + if ( ! empty($pConfig) && ! empty($pConfig['name'])) { |
|
317 | 317 | $pMetadata->name = (string) $pConfig['name']; |
318 | 318 | } |
319 | 319 | |
320 | - if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
320 | + if ((ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
321 | 321 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
322 | 322 | ) { |
323 | 323 | $metadata->addPropertyMetadata($pMetadata); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | private function addClassProperties(ClassMetadata $metadata, array $config): void |
362 | 362 | { |
363 | - if (isset($config['custom_accessor_order']) && !isset($config['accessor_order'])) { |
|
363 | + if (isset($config['custom_accessor_order']) && ! isset($config['accessor_order'])) { |
|
364 | 364 | $config['accessor_order'] = 'custom'; |
365 | 365 | } |
366 | 366 | |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | if (isset($config['discriminator']['disabled']) && true === $config['discriminator']['disabled']) { |
391 | 391 | $metadata->discriminatorDisabled = true; |
392 | 392 | } else { |
393 | - if (!isset($config['discriminator']['field_name'])) { |
|
393 | + if ( ! isset($config['discriminator']['field_name'])) { |
|
394 | 394 | throw new InvalidMetadataException('The "field_name" attribute must be set for discriminators.'); |
395 | 395 | } |
396 | 396 | |
397 | - if (!isset($config['discriminator']['map']) || !is_array($config['discriminator']['map'])) { |
|
397 | + if ( ! isset($config['discriminator']['map']) || ! is_array($config['discriminator']['map'])) { |
|
398 | 398 | throw new InvalidMetadataException( |
399 | 399 | 'The "map" attribute must be set, and be an array for discriminators.' |
400 | 400 | ); |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | { |
429 | 429 | if (is_string($config)) { |
430 | 430 | $config = [$config]; |
431 | - } elseif (!is_array($config)) { |
|
431 | + } elseif ( ! is_array($config)) { |
|
432 | 432 | throw new InvalidMetadataException( |
433 | 433 | sprintf( |
434 | 434 | 'callback methods expects a string, or an array of strings that represent method names, but got %s.', |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | |
440 | 440 | $methods = []; |
441 | 441 | foreach ($config as $name) { |
442 | - if (!$class->hasMethod($name)) { |
|
442 | + if ( ! $class->hasMethod($name)) { |
|
443 | 443 | throw new InvalidMetadataException( |
444 | 444 | sprintf('The method %s does not exist in class %s.', $name, $class->name) |
445 | 445 | ); |