@@ -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 | ); |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | ); |
| 131 | 131 | unset($propertySettings['exp']); |
| 132 | 132 | } else { |
| 133 | - if (!$class->hasMethod($methodName)) { |
|
| 133 | + if ( ! $class->hasMethod($methodName)) { |
|
| 134 | 134 | throw new InvalidMetadataException( |
| 135 | - 'The method ' . $methodName . ' not found in class ' . $class->name |
|
| 135 | + 'The method '.$methodName.' not found in class '.$class->name |
|
| 136 | 136 | ); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if (!$excludeAll) { |
|
| 147 | + if ( ! $excludeAll) { |
|
| 148 | 148 | foreach ($class->getProperties() as $property) { |
| 149 | 149 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
| 150 | 150 | continue; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | $pName = $property->getName(); |
| 154 | 154 | $propertiesMetadata[] = new PropertyMetadata($name, $pName); |
| 155 | - $propertiesData[] = !empty($config['properties']) && true === array_key_exists($pName, $config['properties']) |
|
| 155 | + $propertiesData[] = ! empty($config['properties']) && true === array_key_exists($pName, $config['properties']) |
|
| 156 | 156 | ? (array) $config['properties'][$pName] |
| 157 | 157 | : null; |
| 158 | 158 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | || isset($propertiesData[$propertyKey]); |
| 165 | 165 | |
| 166 | 166 | $pConfig = $propertiesData[$propertyKey]; |
| 167 | - if (!empty($pConfig)) { |
|
| 167 | + if ( ! empty($pConfig)) { |
|
| 168 | 168 | if (isset($pConfig['exclude'])) { |
| 169 | 169 | $isExclude = (bool) $pConfig['exclude']; |
| 170 | 170 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | if (isset($pConfig['expose_if'])) { |
| 197 | - $pMetadata->excludeIf = $this->parseExpression('!(' . $pConfig['expose_if'] . ')'); |
|
| 197 | + $pMetadata->excludeIf = $this->parseExpression('!('.$pConfig['expose_if'].')'); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | if (isset($pConfig['serialized_name'])) { |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if (!$pMetadata->serializedName) { |
|
| 305 | + if ( ! $pMetadata->serializedName) { |
|
| 306 | 306 | $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | $metadata->isMap = $metadata->isMap || PropertyMetadata::isCollectionMap($pMetadata->type); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - if (!empty($pConfig) && !empty($pConfig['name'])) { |
|
| 314 | + if ( ! empty($pConfig) && ! empty($pConfig['name'])) { |
|
| 315 | 315 | $pMetadata->name = (string) $pConfig['name']; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | if ( |
| 319 | - (ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
| 319 | + (ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
| 320 | 320 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
| 321 | 321 | ) { |
| 322 | 322 | $metadata->addPropertyMetadata($pMetadata); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | |
| 362 | 362 | private function addClassProperties(ClassMetadata $metadata, array $config): void |
| 363 | 363 | { |
| 364 | - if (isset($config['custom_accessor_order']) && !isset($config['accessor_order'])) { |
|
| 364 | + if (isset($config['custom_accessor_order']) && ! isset($config['accessor_order'])) { |
|
| 365 | 365 | $config['accessor_order'] = 'custom'; |
| 366 | 366 | } |
| 367 | 367 | |
@@ -391,11 +391,11 @@ discard block |
||
| 391 | 391 | if (isset($config['discriminator']['disabled']) && true === $config['discriminator']['disabled']) { |
| 392 | 392 | $metadata->discriminatorDisabled = true; |
| 393 | 393 | } else { |
| 394 | - if (!isset($config['discriminator']['field_name'])) { |
|
| 394 | + if ( ! isset($config['discriminator']['field_name'])) { |
|
| 395 | 395 | throw new InvalidMetadataException('The "field_name" attribute must be set for discriminators.'); |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - if (!isset($config['discriminator']['map']) || !is_array($config['discriminator']['map'])) { |
|
| 398 | + if ( ! isset($config['discriminator']['map']) || ! is_array($config['discriminator']['map'])) { |
|
| 399 | 399 | throw new InvalidMetadataException( |
| 400 | 400 | 'The "map" attribute must be set, and be an array for discriminators.' |
| 401 | 401 | ); |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | { |
| 433 | 433 | if (is_string($config)) { |
| 434 | 434 | $config = [$config]; |
| 435 | - } elseif (!is_array($config)) { |
|
| 435 | + } elseif ( ! is_array($config)) { |
|
| 436 | 436 | throw new InvalidMetadataException( |
| 437 | 437 | sprintf( |
| 438 | 438 | 'callback methods expects a string, or an array of strings that represent method names, but got %s.', |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | |
| 444 | 444 | $methods = []; |
| 445 | 445 | foreach ($config as $name) { |
| 446 | - if (!$class->hasMethod($name)) { |
|
| 446 | + if ( ! $class->hasMethod($name)) { |
|
| 447 | 447 | throw new InvalidMetadataException( |
| 448 | 448 | sprintf('The method %s does not exist in class %s.', $name, $class->name) |
| 449 | 449 | ); |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | protected function setDiscriminator(DoctrineClassMetadata $doctrineMetadata, ClassMetadata $classMetadata): void |
| 18 | 18 | { |
| 19 | 19 | if ( |
| 20 | - empty($classMetadata->discriminatorMap) && !$classMetadata->discriminatorDisabled |
|
| 21 | - && !empty($doctrineMetadata->discriminatorMap) && $doctrineMetadata->isRootEntity() |
|
| 20 | + empty($classMetadata->discriminatorMap) && ! $classMetadata->discriminatorDisabled |
|
| 21 | + && ! empty($doctrineMetadata->discriminatorMap) && $doctrineMetadata->isRootEntity() |
|
| 22 | 22 | ) { |
| 23 | 23 | $classMetadata->setDiscriminator( |
| 24 | 24 | $doctrineMetadata->discriminatorColumn['name'], |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | // For inheritance schemes, we cannot add any type as we would only add the super-type of the hierarchy. |
| 47 | 47 | // On serialization, this would lead to only the supertype being serialized, and properties of subtypes |
| 48 | 48 | // being ignored. |
| 49 | - if ($targetMetadata instanceof DoctrineClassMetadata && !$targetMetadata->isInheritanceTypeNone()) { |
|
| 49 | + if ($targetMetadata instanceof DoctrineClassMetadata && ! $targetMetadata->isInheritanceTypeNone()) { |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if (!$doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
| 53 | + if ( ! $doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
| 54 | 54 | $targetEntity = sprintf('ArrayCollection<%s>', $targetEntity); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | && ($fieldType = $this->normalizeFieldType($typeOfFiled)) |
| 30 | 30 | ) { |
| 31 | 31 | $field = $doctrineMetadata->getFieldMapping($propertyName); |
| 32 | - if (!empty($field['multivalue'])) { |
|
| 32 | + if ( ! empty($field['multivalue'])) { |
|
| 33 | 33 | $fieldType = 'array'; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | return; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if (!$doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
| 48 | + if ( ! $doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
| 49 | 49 | $targetEntity = sprintf('ArrayCollection<%s>', $targetEntity); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -54,14 +54,14 @@ 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 | |
| 61 | 61 | $elem = reset($elems); |
| 62 | 62 | |
| 63 | 63 | $metadata->fileResources[] = $path; |
| 64 | - $fileResource = $class->getFilename(); |
|
| 64 | + $fileResource = $class->getFilename(); |
|
| 65 | 65 | if (false !== $fileResource) { |
| 66 | 66 | $metadata->fileResources[] = $fileResource; |
| 67 | 67 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $discriminatorFieldName = (string) $elem->attributes()->{'discriminator-field-name'}; |
| 101 | 101 | $discriminatorMap = []; |
| 102 | 102 | foreach ($elem->xpath('./discriminator-class') as $entry) { |
| 103 | - if (!isset($entry->attributes()->value)) { |
|
| 103 | + if ( ! isset($entry->attributes()->value)) { |
|
| 104 | 104 | throw new InvalidMetadataException('Each discriminator-class element must have a "value" attribute.'); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | if ('true' === (string) $elem->attributes()->{'discriminator-disabled'}) { |
| 111 | 111 | $metadata->discriminatorDisabled = true; |
| 112 | - } elseif (!empty($discriminatorFieldName) || !empty($discriminatorMap)) { |
|
| 112 | + } elseif ( ! empty($discriminatorFieldName) || ! empty($discriminatorMap)) { |
|
| 113 | 113 | $discriminatorGroups = []; |
| 114 | 114 | foreach ($elem->xpath('./discriminator-groups/group') as $entry) { |
| 115 | 115 | $discriminatorGroups[] = (string) $entry; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | foreach ($elem->xpath('./xml-namespace') as $xmlNamespace) { |
| 122 | - if (!isset($xmlNamespace->attributes()->uri)) { |
|
| 122 | + if ( ! isset($xmlNamespace->attributes()->uri)) { |
|
| 123 | 123 | throw new InvalidMetadataException('The prefix attribute must be set for all xml-namespace elements.'); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $this->parseExpression((string) $method->attributes()->expression) |
| 155 | 155 | ); |
| 156 | 156 | } else { |
| 157 | - if (!isset($method->attributes()->method)) { |
|
| 157 | + if ( ! isset($method->attributes()->method)) { |
|
| 158 | 158 | throw new InvalidMetadataException('The method attribute must be set for all virtual-property elements.'); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $propertiesNodes[] = $method; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if (!$excludeAll) { |
|
| 168 | + if ( ! $excludeAll) { |
|
| 169 | 169 | foreach ($class->getProperties() as $property) { |
| 170 | 170 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
| 171 | 171 | continue; |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $pName = $property->getName(); |
| 175 | 175 | $propertiesMetadata[] = new PropertyMetadata($name, $pName); |
| 176 | 176 | |
| 177 | - $pElems = $elem->xpath("./property[@name = '" . $pName . "']"); |
|
| 177 | + $pElems = $elem->xpath("./property[@name = '".$pName."']"); |
|
| 178 | 178 | $propertiesNodes[] = $pElems ? reset($pElems) : null; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | || isset($propertiesNodes[$propertyKey]); |
| 186 | 186 | |
| 187 | 187 | $pElem = $propertiesNodes[$propertyKey]; |
| 188 | - if (!empty($pElem)) { |
|
| 188 | + if ( ! empty($pElem)) { |
|
| 189 | 189 | if (null !== $exclude = $pElem->attributes()->exclude) { |
| 190 | 190 | $isExclude = 'true' === strtolower((string) $exclude); |
| 191 | 191 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | if (null !== $excludeIf = $pElem->attributes()->{'expose-if'}) { |
| 210 | - $pMetadata->excludeIf = $this->parseExpression('!(' . (string) $excludeIf . ')'); |
|
| 210 | + $pMetadata->excludeIf = $this->parseExpression('!('.(string) $excludeIf.')'); |
|
| 211 | 211 | $isExpose = true; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -335,16 +335,16 @@ discard block |
||
| 335 | 335 | $metadata->isMap = $metadata->isMap || PropertyMetadata::isCollectionMap($pMetadata->type); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if (!$pMetadata->serializedName) { |
|
| 338 | + if ( ! $pMetadata->serializedName) { |
|
| 339 | 339 | $pMetadata->serializedName = $this->namingStrategy->translateName($pMetadata); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if (!empty($pElem) && null !== $name = $pElem->attributes()->name) { |
|
| 342 | + if ( ! empty($pElem) && null !== $name = $pElem->attributes()->name) { |
|
| 343 | 343 | $pMetadata->name = (string) $name; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | if ( |
| 347 | - (ExclusionPolicy::NONE === (string) $exclusionPolicy && !$isExclude) |
|
| 347 | + (ExclusionPolicy::NONE === (string) $exclusionPolicy && ! $isExclude) |
|
| 348 | 348 | || (ExclusionPolicy::ALL === (string) $exclusionPolicy && $isExpose) |
| 349 | 349 | ) { |
| 350 | 350 | $metadata->addPropertyMetadata($pMetadata); |
@@ -353,11 +353,11 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | foreach ($elem->xpath('./callback-method') as $method) { |
| 356 | - if (!isset($method->attributes()->type)) { |
|
| 356 | + if ( ! isset($method->attributes()->type)) { |
|
| 357 | 357 | throw new InvalidMetadataException('The type attribute must be set for all callback-method elements.'); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if (!isset($method->attributes()->name)) { |
|
| 360 | + if ( ! isset($method->attributes()->name)) { |
|
| 361 | 361 | throw new InvalidMetadataException('The name attribute must be set for all callback-method elements.'); |
| 362 | 362 | } |
| 363 | 363 | |
@@ -375,11 +375,11 @@ discard block |
||
| 375 | 375 | break; |
| 376 | 376 | |
| 377 | 377 | case 'handler': |
| 378 | - if (!isset($method->attributes()->format)) { |
|
| 378 | + if ( ! isset($method->attributes()->format)) { |
|
| 379 | 379 | throw new InvalidMetadataException('The format attribute must be set for "handler" callback methods.'); |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if (!isset($method->attributes()->direction)) { |
|
| 382 | + if ( ! isset($method->attributes()->direction)) { |
|
| 383 | 383 | throw new InvalidMetadataException('The direction attribute must be set for "handler" callback methods.'); |
| 384 | 384 | } |
| 385 | 385 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | \assert($classMetadata instanceof ClassMetadata); |
| 84 | 84 | |
| 85 | 85 | // Abort if the given class is not a mapped entity |
| 86 | - if (!$doctrineMetadata = $this->tryLoadingDoctrineMetadata($class->name)) { |
|
| 86 | + if ( ! $doctrineMetadata = $this->tryLoadingDoctrineMetadata($class->name)) { |
|
| 87 | 87 | return $classMetadata; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | protected function tryLoadingDoctrineMetadata(string $className): ?DoctrineClassMetadata |
| 131 | 131 | { |
| 132 | - if (!$manager = $this->registry->getManagerForClass($className)) { |
|
| 132 | + if ( ! $manager = $this->registry->getManagerForClass($className)) { |
|
| 133 | 133 | return null; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | protected function normalizeFieldType(string $type): ?string |
| 144 | 144 | { |
| 145 | - if (!isset($this->fieldMapping[$type])) { |
|
| 145 | + if ( ! isset($this->fieldMapping[$type])) { |
|
| 146 | 146 | return null; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public function loadMetadataForClass(\ReflectionClass $class): ?BaseClassMetadata |
| 78 | 78 | { |
| 79 | 79 | $classMetadata = new ClassMetadata($name = $class->name); |
| 80 | - $fileResource = $class->getFilename(); |
|
| 80 | + $fileResource = $class->getFilename(); |
|
| 81 | 81 | if (false !== $fileResource) { |
| 82 | 82 | $classMetadata->fileResources[] = $fileResource; |
| 83 | 83 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if (!$excludeAll) { |
|
| 160 | + if ( ! $excludeAll) { |
|
| 161 | 161 | foreach ($class->getProperties() as $property) { |
| 162 | 162 | if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) { |
| 163 | 163 | continue; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } elseif ($annot instanceof Expose) { |
| 190 | 190 | $isExpose = true; |
| 191 | 191 | if (null !== $annot->if) { |
| 192 | - $propertyMetadata->excludeIf = $this->parseExpression('!(' . $annot->if . ')'); |
|
| 192 | + $propertyMetadata->excludeIf = $this->parseExpression('!('.$annot->if.')'); |
|
| 193 | 193 | } |
| 194 | 194 | } elseif ($annot instanceof Exclude) { |
| 195 | 195 | if (null !== $annot->if) { |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | throw new InvalidMetadataException(sprintf( |
| 239 | 239 | 'Invalid group name "%s" on "%s", did you mean to create multiple groups?', |
| 240 | 240 | implode(', ', $propertyMetadata->groups), |
| 241 | - $propertyMetadata->class . '->' . $propertyMetadata->name |
|
| 241 | + $propertyMetadata->class.'->'.$propertyMetadata->name |
|
| 242 | 242 | )); |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if (!$propertyMetadata->serializedName) { |
|
| 263 | + if ( ! $propertyMetadata->serializedName) { |
|
| 264 | 264 | $propertyMetadata->serializedName = $this->namingStrategy->translateName($propertyMetadata); |
| 265 | 265 | } |
| 266 | 266 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | if ( |
| 274 | - (ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude) |
|
| 274 | + (ExclusionPolicy::NONE === $exclusionPolicy && ! $isExclude) |
|
| 275 | 275 | || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose) |
| 276 | 276 | ) { |
| 277 | 277 | $propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function startVisiting($object): void |
| 66 | 66 | { |
| 67 | - if (!\is_object($object)) { |
|
| 67 | + if ( ! \is_object($object)) { |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function stopVisiting($object): void |
| 79 | 79 | { |
| 80 | - if (!\is_object($object)) { |
|
| 80 | + if ( ! \is_object($object)) { |
|
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function isVisiting($object): bool |
| 96 | 96 | { |
| 97 | - if (!\is_object($object)) { |
|
| 97 | + if ( ! \is_object($object)) { |
|
| 98 | 98 | return false; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $path[] = \get_class($obj); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if (!$path) { |
|
| 111 | + if ( ! $path) { |
|
| 112 | 112 | return null; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function getObject(): ?object |
| 129 | 129 | { |
| 130 | - return !$this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
| 130 | + return ! $this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function getVisitingStack(): \SplStack |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | |
| 32 | 32 | public function translateName(PropertyMetadata $property): string |
| 33 | 33 | { |
| 34 | - $name = preg_replace('/[A-Z]+/', $this->separator . '\\0', $property->name); |
|
| 34 | + $name = preg_replace('/[A-Z]+/', $this->separator.'\\0', $property->name); |
|
| 35 | 35 | |
| 36 | 36 | if ($this->lowerCase) { |
| 37 | 37 | return strtolower($name); |
@@ -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 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $node = $this->navigator->accept($v, $metadata->type); |
| 246 | 246 | $this->revertCurrentMetadata(); |
| 247 | 247 | |
| 248 | - if (!$node instanceof \DOMCharacterData) { |
|
| 248 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 249 | 249 | throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v))); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | if ( |
| 258 | 258 | ($metadata->xmlValue && $this->currentNode->childNodes->length > 0) |
| 259 | - || (!$metadata->xmlValue && $this->hasValue) |
|
| 259 | + || ( ! $metadata->xmlValue && $this->hasValue) |
|
| 260 | 260 | ) { |
| 261 | 261 | 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)); |
| 262 | 262 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $node = $this->navigator->accept($v, $metadata->type); |
| 269 | 269 | $this->revertCurrentMetadata(); |
| 270 | 270 | |
| 271 | - if (!$node instanceof \DOMCharacterData) { |
|
| 271 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 272 | 272 | 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))); |
| 273 | 273 | } |
| 274 | 274 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | if ($metadata->xmlAttributeMap) { |
| 281 | - if (!\is_array($v)) { |
|
| 281 | + if ( ! \is_array($v)) { |
|
| 282 | 282 | throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', \gettype($v))); |
| 283 | 283 | } |
| 284 | 284 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $node = $this->navigator->accept($value, null); |
| 288 | 288 | $this->revertCurrentMetadata(); |
| 289 | 289 | |
| 290 | - if (!$node instanceof \DOMCharacterData) { |
|
| 290 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 291 | 291 | throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v))); |
| 292 | 292 | } |
| 293 | 293 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | return; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { |
|
| 300 | + if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) { |
|
| 301 | 301 | $namespace = null !== $metadata->xmlNamespace |
| 302 | 302 | ? $metadata->xmlNamespace |
| 303 | 303 | : $this->getClassDefaultNamespace($this->objectMetadataStack->top()); |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | private function isSkippableEmptyObject(?\DOMElement $node, PropertyMetadata $metadata): bool |
| 344 | 344 | { |
| 345 | - return null === $node && !$metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 345 | + return null === $node && ! $metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | private function isSkippableCollection(PropertyMetadata $metadata): bool |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | private function isElementEmpty(\DOMElement $element): bool |
| 354 | 354 | { |
| 355 | - return !$element->hasChildNodes() && !$element->hasAttributes(); |
|
| 355 | + return ! $element->hasChildNodes() && ! $element->hasAttributes(); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | public function endVisitingObject(ClassMetadata $metadata, object $data, array $type): void |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | foreach ($metadata->xmlNamespaces as $prefix => $uri) { |
| 461 | 461 | $attribute = 'xmlns'; |
| 462 | 462 | if ('' !== $prefix) { |
| 463 | - $attribute .= ':' . $prefix; |
|
| 463 | + $attribute .= ':'.$prefix; |
|
| 464 | 464 | } elseif ($element->namespaceURI === $uri) { |
| 465 | 465 | continue; |
| 466 | 466 | } |
@@ -490,21 +490,21 @@ discard block |
||
| 490 | 490 | return $this->document->createElementNS($namespace, $tagName); |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 494 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 493 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 494 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
| 497 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | private function setAttributeOnNode(\DOMElement $node, string $name, string $value, ?string $namespace = null): void |
| 501 | 501 | { |
| 502 | 502 | if (null !== $namespace) { |
| 503 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
| 504 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 503 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
| 504 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - $node->setAttributeNS($namespace, $prefix . ':' . $name, $value); |
|
| 507 | + $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
|
| 508 | 508 | } else { |
| 509 | 509 | $node->setAttribute($name, $value); |
| 510 | 510 | } |