@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $metadata = new ClassMetadata($name = $class->name); |
| 57 | - if (!$elems = $elem->xpath("./class[@name = '" . $name . "']")) { |
|
| 57 | + if ( ! $elems = $elem->xpath("./class[@name = '".$name."']")) { |
|
| 58 | 58 | throw new InvalidMetadataException(sprintf('Could not find class %s inside XML element.', $name)); |
| 59 | 59 | } |
| 60 | 60 | $elem = reset($elems); |
| 61 | 61 | |
| 62 | 62 | $metadata->fileResources[] = $path; |
| 63 | - $fileResource = $class->getFilename(); |
|
| 63 | + $fileResource = $class->getFilename(); |
|
| 64 | 64 | if (false !== $fileResource) { |
| 65 | 65 | $metadata->fileResources[] = $fileResource; |
| 66 | 66 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $discriminatorFieldName = (string) $elem->attributes()->{'discriminator-field-name'}; |
| 93 | 93 | $discriminatorMap = []; |
| 94 | 94 | foreach ($elem->xpath('./discriminator-class') as $entry) { |
| 95 | - if (!isset($entry->attributes()->value)) { |
|
| 95 | + if ( ! isset($entry->attributes()->value)) { |
|
| 96 | 96 | throw new InvalidMetadataException('Each discriminator-class element must have a "value" attribute.'); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | if ('true' === (string) $elem->attributes()->{'discriminator-disabled'}) { |
| 103 | 103 | $metadata->discriminatorDisabled = true; |
| 104 | - } elseif (!empty($discriminatorFieldName) || !empty($discriminatorMap)) { |
|
| 104 | + } elseif ( ! empty($discriminatorFieldName) || ! empty($discriminatorMap)) { |
|
| 105 | 105 | $discriminatorGroups = []; |
| 106 | 106 | foreach ($elem->xpath('./discriminator-groups/group') as $entry) { |
| 107 | 107 | $discriminatorGroups[] = (string) $entry; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | foreach ($elem->xpath('./xml-namespace') as $xmlNamespace) { |
| 113 | - if (!isset($xmlNamespace->attributes()->uri)) { |
|
| 113 | + if ( ! isset($xmlNamespace->attributes()->uri)) { |
|
| 114 | 114 | throw new InvalidMetadataException('The prefix attribute must be set for all xml-namespace elements.'); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $this->parseExpression((string) $method->attributes()->expression) |
| 144 | 144 | ); |
| 145 | 145 | } else { |
| 146 | - if (!isset($method->attributes()->method)) { |
|
| 146 | + if ( ! isset($method->attributes()->method)) { |
|
| 147 | 147 | throw new InvalidMetadataException('The method attribute must be set for all virtual-property elements.'); |
| 148 | 148 | } |
| 149 | 149 | $virtualPropertyMetadata = new VirtualPropertyMetadata($name, (string) $method->attributes()->method); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $propertiesNodes[] = $method; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if (!$excludeAll) { |
|
| 156 | + if ( ! $excludeAll) { |
|
| 157 | 157 | foreach ($class->getProperties() as $property) { |
| 158 | 158 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
| 159 | 159 | continue; |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $pName = $property->getName(); |
| 162 | 162 | $propertiesMetadata[] = new PropertyMetadata($name, $pName); |
| 163 | 163 | |
| 164 | - $pElems = $elem->xpath("./property[@name = '" . $pName . "']"); |
|
| 164 | + $pElems = $elem->xpath("./property[@name = '".$pName."']"); |
|
| 165 | 165 | $propertiesNodes[] = $pElems ? reset($pElems) : null; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | || isset($propertiesNodes[$propertyKey]); |
| 173 | 173 | |
| 174 | 174 | $pElem = $propertiesNodes[$propertyKey]; |
| 175 | - if (!empty($pElem)) { |
|
| 175 | + if ( ! empty($pElem)) { |
|
| 176 | 176 | if (null !== $exclude = $pElem->attributes()->exclude) { |
| 177 | 177 | $isExclude = 'true' === strtolower((string) $exclude); |
| 178 | 178 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | if (null !== $excludeIf = $pElem->attributes()->{'expose-if'}) { |
| 197 | - $pMetadata->excludeIf = $this->parseExpression('!(' . (string) $excludeIf . ')'); |
|
| 197 | + $pMetadata->excludeIf = $this->parseExpression('!('.(string) $excludeIf.')'); |
|
| 198 | 198 | $isExpose = true; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -322,15 +322,15 @@ discard block |
||
| 322 | 322 | $metadata->isMap = $metadata->isMap || PropertyMetadata::isCollectionMap($pMetadata->type); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if (!$pMetadata->serializedName) { |
|
| 325 | + if ( ! $pMetadata->serializedName) { |
|
| 326 | 326 | $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if (!empty($pElem) && null !== $name = $pElem->attributes()->name) { |
|
| 329 | + if ( ! empty($pElem) && null !== $name = $pElem->attributes()->name) { |
|
| 330 | 330 | $pMetadata->name = (string) $name; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - if ((ExclusionPolicy::NONE === (string) $exclusionPolicy && !$isExclude) |
|
| 333 | + if ((ExclusionPolicy::NONE === (string) $exclusionPolicy && ! $isExclude) |
|
| 334 | 334 | || (ExclusionPolicy::ALL === (string) $exclusionPolicy && $isExpose) |
| 335 | 335 | ) { |
| 336 | 336 | $metadata->addPropertyMetadata($pMetadata); |
@@ -339,10 +339,10 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | foreach ($elem->xpath('./callback-method') as $method) { |
| 342 | - if (!isset($method->attributes()->type)) { |
|
| 342 | + if ( ! isset($method->attributes()->type)) { |
|
| 343 | 343 | throw new InvalidMetadataException('The type attribute must be set for all callback-method elements.'); |
| 344 | 344 | } |
| 345 | - if (!isset($method->attributes()->name)) { |
|
| 345 | + if ( ! isset($method->attributes()->name)) { |
|
| 346 | 346 | throw new InvalidMetadataException('The name attribute must be set for all callback-method elements.'); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | break; |
| 361 | 361 | |
| 362 | 362 | case 'handler': |
| 363 | - if (!isset($method->attributes()->format)) { |
|
| 363 | + if ( ! isset($method->attributes()->format)) { |
|
| 364 | 364 | throw new InvalidMetadataException('The format attribute must be set for "handler" callback methods.'); |
| 365 | 365 | } |
| 366 | - if (!isset($method->attributes()->direction)) { |
|
| 366 | + if ( ! isset($method->attributes()->direction)) { |
|
| 367 | 367 | throw new InvalidMetadataException('The direction attribute must be set for "handler" callback methods.'); |
| 368 | 368 | } |
| 369 | 369 | |
@@ -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 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
| 144 | 144 | continue; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $pName = $property->getName(); |
| 148 | 148 | $propertiesMetadata[] = new PropertyMetadata($name, $pName); |
| 149 | - $propertiesData[] = !empty($config['properties']) && true === array_key_exists($pName, $config['properties']) |
|
| 149 | + $propertiesData[] = ! empty($config['properties']) && true === array_key_exists($pName, $config['properties']) |
|
| 150 | 150 | ? (array) $config['properties'][$pName] |
| 151 | 151 | : null; |
| 152 | 152 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | || isset($propertiesData[$propertyKey]); |
| 159 | 159 | |
| 160 | 160 | $pConfig = $propertiesData[$propertyKey]; |
| 161 | - if (!empty($pConfig)) { |
|
| 161 | + if ( ! empty($pConfig)) { |
|
| 162 | 162 | if (isset($pConfig['exclude'])) { |
| 163 | 163 | $isExclude = (bool) $pConfig['exclude']; |
| 164 | 164 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | if (isset($pConfig['expose_if'])) { |
| 191 | - $pMetadata->excludeIf = $this->parseExpression('!(' . $pConfig['expose_if'] . ')'); |
|
| 191 | + $pMetadata->excludeIf = $this->parseExpression('!('.$pConfig['expose_if'].')'); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | if (isset($pConfig['serialized_name'])) { |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - if (!$pMetadata->serializedName) { |
|
| 299 | + if ( ! $pMetadata->serializedName) { |
|
| 300 | 300 | $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata); |
| 301 | 301 | } |
| 302 | 302 | |
@@ -305,11 +305,11 @@ discard block |
||
| 305 | 305 | $metadata->isMap = $metadata->isMap || PropertyMetadata::isCollectionMap($pMetadata->type); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if (!empty($pConfig) && !empty($pConfig['name'])) { |
|
| 308 | + if ( ! empty($pConfig) && ! empty($pConfig['name'])) { |
|
| 309 | 309 | $pMetadata->name = (string) $pConfig['name']; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
| 312 | + if ((ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
| 313 | 313 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
| 314 | 314 | ) { |
| 315 | 315 | $metadata->addPropertyMetadata($pMetadata); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | private function addClassProperties(ClassMetadata $metadata, array $config): void |
| 354 | 354 | { |
| 355 | - if (isset($config['custom_accessor_order']) && !isset($config['accessor_order'])) { |
|
| 355 | + if (isset($config['custom_accessor_order']) && ! isset($config['accessor_order'])) { |
|
| 356 | 356 | $config['accessor_order'] = 'custom'; |
| 357 | 357 | } |
| 358 | 358 | |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | if (isset($config['discriminator']['disabled']) && true === $config['discriminator']['disabled']) { |
| 383 | 383 | $metadata->discriminatorDisabled = true; |
| 384 | 384 | } else { |
| 385 | - if (!isset($config['discriminator']['field_name'])) { |
|
| 385 | + if ( ! isset($config['discriminator']['field_name'])) { |
|
| 386 | 386 | throw new InvalidMetadataException('The "field_name" attribute must be set for discriminators.'); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - if (!isset($config['discriminator']['map']) || !is_array($config['discriminator']['map'])) { |
|
| 389 | + if ( ! isset($config['discriminator']['map']) || ! is_array($config['discriminator']['map'])) { |
|
| 390 | 390 | throw new InvalidMetadataException( |
| 391 | 391 | 'The "map" attribute must be set, and be an array for discriminators.' |
| 392 | 392 | ); |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | { |
| 421 | 421 | if (is_string($config)) { |
| 422 | 422 | $config = [$config]; |
| 423 | - } elseif (!is_array($config)) { |
|
| 423 | + } elseif ( ! is_array($config)) { |
|
| 424 | 424 | throw new InvalidMetadataException( |
| 425 | 425 | sprintf( |
| 426 | 426 | 'callback methods expects a string, or an array of strings that represent method names, but got %s.', |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | $methods = []; |
| 433 | 433 | foreach ($config as $name) { |
| 434 | - if (!$class->hasMethod($name)) { |
|
| 434 | + if ( ! $class->hasMethod($name)) { |
|
| 435 | 435 | throw new InvalidMetadataException( |
| 436 | 436 | sprintf('The method %s does not exist in class %s.', $name, $class->name) |
| 437 | 437 | ); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | && ($typeOfFiled = $doctrineMetadata->getTypeOfField($propertyName)) |
| 28 | 28 | && ($fieldType = $this->normalizeFieldType($typeOfFiled))) { |
| 29 | 29 | $field = $doctrineMetadata->getFieldMapping($propertyName); |
| 30 | - if (!empty($field['multivalue'])) { |
|
| 30 | + if ( ! empty($field['multivalue'])) { |
|
| 31 | 31 | $fieldType = 'array'; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | return; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if (!$doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
| 46 | + if ( ! $doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
| 47 | 47 | $targetEntity = sprintf('ArrayCollection<%s>', $targetEntity); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | private function getAccessorStrategy(): AccessorStrategyInterface |
| 201 | 201 | { |
| 202 | - if (!$this->accessorStrategy) { |
|
| 202 | + if ( ! $this->accessorStrategy) { |
|
| 203 | 203 | $this->accessorStrategy = new DefaultAccessorStrategy($this->expressionEvaluator); |
| 204 | 204 | } |
| 205 | 205 | return $this->accessorStrategy; |
@@ -235,10 +235,10 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | public function setCacheDir(string $dir): self |
| 237 | 237 | { |
| 238 | - if (!is_dir($dir)) { |
|
| 238 | + if ( ! is_dir($dir)) { |
|
| 239 | 239 | $this->createDir($dir); |
| 240 | 240 | } |
| 241 | - if (!is_writable($dir)) { |
|
| 241 | + if ( ! is_writable($dir)) { |
|
| 242 | 242 | throw new InvalidArgumentException(sprintf('The cache directory "%s" is not writable.', $dir)); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | public function setMetadataDirs(array $namespacePrefixToDirMap): self |
| 361 | 361 | { |
| 362 | 362 | foreach ($namespacePrefixToDirMap as $dir) { |
| 363 | - if (!is_dir($dir)) { |
|
| 363 | + if ( ! is_dir($dir)) { |
|
| 364 | 364 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
| 365 | 365 | } |
| 366 | 366 | } |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public function addMetadataDir(string $dir, string $namespacePrefix = ''): self |
| 400 | 400 | { |
| 401 | - if (!is_dir($dir)) { |
|
| 401 | + if ( ! is_dir($dir)) { |
|
| 402 | 402 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
| 403 | 403 | } |
| 404 | 404 | |
@@ -437,11 +437,11 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | public function replaceMetadataDir(string $dir, string $namespacePrefix = ''): self |
| 439 | 439 | { |
| 440 | - if (!is_dir($dir)) { |
|
| 440 | + if ( ! is_dir($dir)) { |
|
| 441 | 441 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if (!isset($this->metadataDirs[$namespacePrefix])) { |
|
| 444 | + if ( ! isset($this->metadataDirs[$namespacePrefix])) { |
|
| 445 | 445 | throw new InvalidArgumentException(sprintf('There is no directory configured for namespace prefix "%s". Please use addMetadataDir() for adding new directories.', $namespacePrefix)); |
| 446 | 446 | } |
| 447 | 447 | |
@@ -506,8 +506,8 @@ discard block |
||
| 506 | 506 | $annotationReader = new AnnotationReader(); |
| 507 | 507 | |
| 508 | 508 | if (null !== $this->cacheDir) { |
| 509 | - $this->createDir($this->cacheDir . '/annotations'); |
|
| 510 | - $annotationsCache = new FilesystemCache($this->cacheDir . '/annotations'); |
|
| 509 | + $this->createDir($this->cacheDir.'/annotations'); |
|
| 510 | + $annotationsCache = new FilesystemCache($this->cacheDir.'/annotations'); |
|
| 511 | 511 | $annotationReader = new CachedReader($annotationReader, $annotationsCache, $this->debug); |
| 512 | 512 | } |
| 513 | 513 | } |
@@ -529,19 +529,19 @@ discard block |
||
| 529 | 529 | if (null !== $this->metadataCache) { |
| 530 | 530 | $metadataFactory->setCache($this->metadataCache); |
| 531 | 531 | } elseif (null !== $this->cacheDir) { |
| 532 | - $this->createDir($this->cacheDir . '/metadata'); |
|
| 533 | - $metadataFactory->setCache(new FileCache($this->cacheDir . '/metadata')); |
|
| 532 | + $this->createDir($this->cacheDir.'/metadata'); |
|
| 533 | + $metadataFactory->setCache(new FileCache($this->cacheDir.'/metadata')); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - if (!$this->handlersConfigured) { |
|
| 536 | + if ( ! $this->handlersConfigured) { |
|
| 537 | 537 | $this->addDefaultHandlers(); |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - if (!$this->listenersConfigured) { |
|
| 540 | + if ( ! $this->listenersConfigured) { |
|
| 541 | 541 | $this->addDefaultListeners(); |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - if (!$this->visitorsAdded) { |
|
| 544 | + if ( ! $this->visitorsAdded) { |
|
| 545 | 545 | $this->addDefaultSerializationVisitors(); |
| 546 | 546 | $this->addDefaultDeserializationVisitors(); |
| 547 | 547 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | foreach ($data as $key => $value) { |
| 40 | - if (!property_exists(self::class, $key)) { |
|
| 40 | + if ( ! property_exists(self::class, $key)) { |
|
| 41 | 41 | throw new InvalidArgumentException(sprintf('Unknown property "%s" on annotation "%s".', $key, self::class)); |
| 42 | 42 | } |
| 43 | 43 | $this->{$key} = $value; |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | $value = $values['policy']; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if (!\is_string($value)) { |
|
| 35 | + if ( ! \is_string($value)) { |
|
| 36 | 36 | throw new RuntimeException('Exclusion policy value must be of string type.'); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | if ($this->nestedGroups) { |
| 61 | 61 | $groups = $this->getGroupsFor($navigatorContext); |
| 62 | 62 | |
| 63 | - if (!$property->groups) { |
|
| 64 | - return !in_array(self::DEFAULT_GROUP, $groups); |
|
| 63 | + if ( ! $property->groups) { |
|
| 64 | + return ! in_array(self::DEFAULT_GROUP, $groups); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return $this->shouldSkipUsingGroups($property, $groups); |
| 68 | 68 | } else { |
| 69 | - if (!$property->groups) { |
|
| 70 | - return !isset($this->groups[self::DEFAULT_GROUP]); |
|
| 69 | + if ( ! $property->groups) { |
|
| 70 | + return ! isset($this->groups[self::DEFAULT_GROUP]); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | foreach ($property->groups as $group) { |
@@ -92,21 +92,21 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public function getGroupsFor(Context $navigatorContext): array |
| 94 | 94 | { |
| 95 | - if (!$this->nestedGroups) { |
|
| 95 | + if ( ! $this->nestedGroups) { |
|
| 96 | 96 | return array_keys($this->groups); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $paths = $navigatorContext->getCurrentPath(); |
| 100 | 100 | $groups = $this->groups; |
| 101 | 101 | foreach ($paths as $index => $path) { |
| 102 | - if (!array_key_exists($path, $groups)) { |
|
| 102 | + if ( ! array_key_exists($path, $groups)) { |
|
| 103 | 103 | if ($index > 0) { |
| 104 | 104 | $groups = [self::DEFAULT_GROUP]; |
| 105 | 105 | } |
| 106 | 106 | break; |
| 107 | 107 | } |
| 108 | 108 | $groups = $groups[$path]; |
| 109 | - if (!array_filter($groups, 'is_string')) { |
|
| 109 | + if ( ! array_filter($groups, 'is_string')) { |
|
| 110 | 110 | $groups += [self::DEFAULT_GROUP]; |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | private function getNavigator(int $direction): GraphNavigatorInterface |
| 116 | 116 | { |
| 117 | - if (!isset($this->graphNavigators[$direction])) { |
|
| 117 | + if ( ! isset($this->graphNavigators[$direction])) { |
|
| 118 | 118 | throw new RuntimeException( |
| 119 | 119 | sprintf( |
| 120 | 120 | 'Can not find a graph navigator for the direction "%s".', |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | ? $this->serializationVisitors |
| 133 | 133 | : $this->deserializationVisitors; |
| 134 | 134 | |
| 135 | - if (!isset($factories[$format])) { |
|
| 135 | + if ( ! isset($factories[$format])) { |
|
| 136 | 136 | throw new UnsupportedFormatException( |
| 137 | 137 | sprintf( |
| 138 | 138 | 'The format "%s" is not supported for %s.', |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $result = $this->visit($navigator, $visitor, $context, $data, 'json', $type); |
| 197 | 197 | $result = $this->convertArrayObjects($result); |
| 198 | 198 | |
| 199 | - if (!\is_array($result)) { |
|
| 199 | + if ( ! \is_array($result)) { |
|
| 200 | 200 | throw new RuntimeException(sprintf( |
| 201 | 201 | 'The input data of type "%s" did not convert to an array, but got a result of type "%s".', |
| 202 | 202 | \is_object($data) ? \get_class($data) : \gettype($data), |
@@ -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 | } |