@@ -70,7 +70,7 @@ |
||
| 70 | 70 | 'direction' => GraphNavigatorInterface::DIRECTION_DESERIALIZATION, |
| 71 | 71 | 'format' => $format, |
| 72 | 72 | 'type' => $class, |
| 73 | - 'method' => 'deserializeUidFrom' . ucfirst($format), |
|
| 73 | + 'method' => 'deserializeUidFrom'.ucfirst($format), |
|
| 74 | 74 | ]; |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, |
| 44 | 44 | 'type' => FormInterface::class, |
| 45 | 45 | 'format' => $format, |
| 46 | - 'method' => 'serializeFormTo' . ucfirst($format), |
|
| 46 | + 'method' => 'serializeFormTo'.ucfirst($format), |
|
| 47 | 47 | ]; |
| 48 | 48 | $methods[] = [ |
| 49 | 49 | 'direction' => GraphNavigatorInterface::DIRECTION_SERIALIZATION, |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function __construct(?object $translator = null, string $translationDomain = 'validators') |
| 59 | 59 | { |
| 60 | - if (null !== $translator && (!$translator instanceof TranslatorInterface && !$translator instanceof TranslatorContract)) { |
|
| 60 | + if (null !== $translator && ( ! $translator instanceof TranslatorInterface && ! $translator instanceof TranslatorContract)) { |
|
| 61 | 61 | throw new \InvalidArgumentException(sprintf( |
| 62 | 62 | 'The first argument passed to %s must be instance of %s or %s, %s given', |
| 63 | 63 | self::class, |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | protected function setDiscriminator(DoctrineClassMetadata $doctrineMetadata, ClassMetadata $classMetadata): void |
| 23 | 23 | { |
| 24 | 24 | if ( |
| 25 | - empty($classMetadata->discriminatorMap) && !$classMetadata->discriminatorDisabled |
|
| 26 | - && !empty($doctrineMetadata->discriminatorMap) && $doctrineMetadata->isRootEntity() |
|
| 25 | + empty($classMetadata->discriminatorMap) && ! $classMetadata->discriminatorDisabled |
|
| 26 | + && ! empty($doctrineMetadata->discriminatorMap) && $doctrineMetadata->isRootEntity() |
|
| 27 | 27 | ) { |
| 28 | 28 | $classMetadata->setDiscriminator( |
| 29 | 29 | $doctrineMetadata->discriminatorColumn['name'], |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | // For inheritance schemes, we cannot add any type as we would only add the super-type of the hierarchy. |
| 52 | 52 | // On serialization, this would lead to only the supertype being serialized, and properties of subtypes |
| 53 | 53 | // being ignored. |
| 54 | - if ($targetMetadata instanceof ClassMetadataInfo && !$targetMetadata->isInheritanceTypeNone()) { |
|
| 54 | + if ($targetMetadata instanceof ClassMetadataInfo && ! $targetMetadata->isInheritanceTypeNone()) { |
|
| 55 | 55 | return; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if (!$doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
| 58 | + if ( ! $doctrineMetadata->isSingleValuedAssociation($propertyName)) { |
|
| 59 | 59 | $targetEntity = sprintf('ArrayCollection<%s>', $targetEntity); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | private function getAccessorStrategy(): AccessorStrategyInterface |
| 216 | 216 | { |
| 217 | - if (!$this->accessorStrategy) { |
|
| 217 | + if ( ! $this->accessorStrategy) { |
|
| 218 | 218 | $this->accessorStrategy = new DefaultAccessorStrategy($this->expressionEvaluator); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | public function setCacheDir(string $dir): self |
| 253 | 253 | { |
| 254 | - if (!is_dir($dir)) { |
|
| 254 | + if ( ! is_dir($dir)) { |
|
| 255 | 255 | $this->createDir($dir); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - if (!is_writable($dir)) { |
|
| 258 | + if ( ! is_writable($dir)) { |
|
| 259 | 259 | throw new InvalidArgumentException(sprintf('The cache directory "%s" is not writable.', $dir)); |
| 260 | 260 | } |
| 261 | 261 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | public function setMetadataDirs(array $namespacePrefixToDirMap): self |
| 378 | 378 | { |
| 379 | 379 | foreach ($namespacePrefixToDirMap as $dir) { |
| 380 | - if (!is_dir($dir)) { |
|
| 380 | + if ( ! is_dir($dir)) { |
|
| 381 | 381 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
| 382 | 382 | } |
| 383 | 383 | } |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | */ |
| 416 | 416 | public function addMetadataDir(string $dir, string $namespacePrefix = ''): self |
| 417 | 417 | { |
| 418 | - if (!is_dir($dir)) { |
|
| 418 | + if ( ! is_dir($dir)) { |
|
| 419 | 419 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
| 420 | 420 | } |
| 421 | 421 | |
@@ -454,11 +454,11 @@ discard block |
||
| 454 | 454 | */ |
| 455 | 455 | public function replaceMetadataDir(string $dir, string $namespacePrefix = ''): self |
| 456 | 456 | { |
| 457 | - if (!is_dir($dir)) { |
|
| 457 | + if ( ! is_dir($dir)) { |
|
| 458 | 458 | throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir)); |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - if (!isset($this->metadataDirs[$namespacePrefix])) { |
|
| 461 | + if ( ! isset($this->metadataDirs[$namespacePrefix])) { |
|
| 462 | 462 | throw new InvalidArgumentException(sprintf('There is no directory configured for namespace prefix "%s". Please use addMetadataDir() for adding new directories.', $namespacePrefix)); |
| 463 | 463 | } |
| 464 | 464 | |
@@ -553,23 +553,23 @@ discard block |
||
| 553 | 553 | if (null !== $this->metadataCache) { |
| 554 | 554 | $metadataFactory->setCache($this->metadataCache); |
| 555 | 555 | } elseif (null !== $this->cacheDir) { |
| 556 | - $this->createDir($this->cacheDir . '/metadata'); |
|
| 557 | - $metadataFactory->setCache(new FileCache($this->cacheDir . '/metadata')); |
|
| 556 | + $this->createDir($this->cacheDir.'/metadata'); |
|
| 557 | + $metadataFactory->setCache(new FileCache($this->cacheDir.'/metadata')); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - if (!$this->handlersConfigured) { |
|
| 560 | + if ( ! $this->handlersConfigured) { |
|
| 561 | 561 | $this->addDefaultHandlers(); |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - if (!$this->listenersConfigured) { |
|
| 564 | + if ( ! $this->listenersConfigured) { |
|
| 565 | 565 | $this->addDefaultListeners(); |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - if (!$this->serializationVisitorsAdded) { |
|
| 568 | + if ( ! $this->serializationVisitorsAdded) { |
|
| 569 | 569 | $this->addDefaultSerializationVisitors(); |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - if (!$this->deserializationVisitorsAdded) { |
|
| 572 | + if ( ! $this->deserializationVisitorsAdded) { |
|
| 573 | 573 | $this->addDefaultDeserializationVisitors(); |
| 574 | 574 | } |
| 575 | 575 | |
@@ -635,12 +635,12 @@ discard block |
||
| 635 | 635 | private function decorateAnnotationReader(Reader $annotationReader): Reader |
| 636 | 636 | { |
| 637 | 637 | if (null !== $this->cacheDir) { |
| 638 | - $this->createDir($this->cacheDir . '/annotations'); |
|
| 638 | + $this->createDir($this->cacheDir.'/annotations'); |
|
| 639 | 639 | if (class_exists(FilesystemAdapter::class)) { |
| 640 | - $annotationsCache = new FilesystemAdapter('', 0, $this->cacheDir . '/annotations'); |
|
| 640 | + $annotationsCache = new FilesystemAdapter('', 0, $this->cacheDir.'/annotations'); |
|
| 641 | 641 | $annotationReader = new PsrCachedReader($annotationReader, $annotationsCache, $this->debug); |
| 642 | 642 | } elseif (class_exists(FilesystemCache::class) && class_exists(CachedReader::class)) { |
| 643 | - $annotationsCache = new FilesystemCache($this->cacheDir . '/annotations'); |
|
| 643 | + $annotationsCache = new FilesystemCache($this->cacheDir.'/annotations'); |
|
| 644 | 644 | $annotationReader = new CachedReader($annotationReader, $annotationsCache, $this->debug); |
| 645 | 645 | } |
| 646 | 646 | } |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | { |
| 75 | 75 | $reflectionType = $propertyReflection->getType(); |
| 76 | 76 | |
| 77 | - if (!($reflectionType instanceof \ReflectionNamedType)) { |
|
| 77 | + if ( ! ($reflectionType instanceof \ReflectionNamedType)) { |
|
| 78 | 78 | return null; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | SerializationContext $context |
| 46 | 46 | ) { |
| 47 | 47 | if (isset($type['params'][1]) && 'value' === $type['params'][1]) { |
| 48 | - if (!$enum instanceof \BackedEnum) { |
|
| 48 | + if ( ! $enum instanceof \BackedEnum) { |
|
| 49 | 49 | throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you can not use "value" as serialization mode for its value.', get_class($enum))); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | $caseValue = (string) $data; |
| 68 | 68 | |
| 69 | 69 | $ref = new \ReflectionEnum($enumType); |
| 70 | - if (isset($type['params'][1]) && 'value' === $type['params'][1] || (!isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) { |
|
| 71 | - if (!is_a($enumType, \BackedEnum::class, true)) { |
|
| 70 | + if (isset($type['params'][1]) && 'value' === $type['params'][1] || ( ! isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) { |
|
| 71 | + if ( ! is_a($enumType, \BackedEnum::class, true)) { |
|
| 72 | 72 | throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you can not use "value" as serialization mode for its value.', $enumType)); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if ('int' === $ref->getBackingType()->getName()) { |
| 76 | - if (!is_numeric($caseValue)) { |
|
| 76 | + if ( ! is_numeric($caseValue)) { |
|
| 77 | 77 | throw new RuntimeException(sprintf('"%s" is not a valid backing value for enum "%s"', $caseValue, $enumType)); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | return $enumType::from($caseValue); |
| 84 | 84 | } else { |
| 85 | - if (!$ref->hasCase($caseValue)) { |
|
| 85 | + if ( ! $ref->hasCase($caseValue)) { |
|
| 86 | 86 | throw new InvalidMetadataException(sprintf('The type "%s" does not have the case "%s"', $ref->getName(), $caseValue)); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | { |
| 14 | 14 | $type = $event->getType(); |
| 15 | 15 | |
| 16 | - if (isset($type['name']) && ('enum' === $type['name'] || !is_a($type['name'], \UnitEnum::class, true))) { |
|
| 16 | + if (isset($type['name']) && ('enum' === $type['name'] || ! is_a($type['name'], \UnitEnum::class, true))) { |
|
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public function visitDouble(float $data, array $type) |
| 72 | 72 | { |
| 73 | 73 | $precision = $type['params'][0] ?? null; |
| 74 | - if (!is_int($precision)) { |
|
| 74 | + if ( ! is_int($precision)) { |
|
| 75 | 75 | return $data; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $rs = isset($type['params'][1]) ? new \ArrayObject() : []; |
| 95 | 95 | |
| 96 | - $isList = isset($type['params'][0]) && !isset($type['params'][1]); |
|
| 96 | + $isList = isset($type['params'][0]) && ! isset($type['params'][1]); |
|
| 97 | 97 | |
| 98 | 98 | $elType = $this->getElementType($type); |
| 99 | 99 | foreach ($data as $k => $v) { |
@@ -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 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $decimalsNumbers = $type['params'][2] ?? null; |
| 191 | 191 | if (null === $decimalsNumbers) { |
| 192 | 192 | $parts = explode('.', (string) $dataResult); |
| 193 | - if (count($parts) < 2 || !$parts[1]) { |
|
| 193 | + if (count($parts) < 2 || ! $parts[1]) { |
|
| 194 | 194 | $decimalsNumbers = 1; |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $node = $this->navigator->accept($v, $metadata->type); |
| 266 | 266 | $this->revertCurrentMetadata(); |
| 267 | 267 | |
| 268 | - if (!$node instanceof \DOMCharacterData) { |
|
| 268 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 269 | 269 | throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v))); |
| 270 | 270 | } |
| 271 | 271 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | if ( |
| 278 | 278 | ($metadata->xmlValue && $this->currentNode->childNodes->length > 0) |
| 279 | - || (!$metadata->xmlValue && $this->hasValue) |
|
| 279 | + || ( ! $metadata->xmlValue && $this->hasValue) |
|
| 280 | 280 | ) { |
| 281 | 281 | 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)); |
| 282 | 282 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $node = $this->navigator->accept($v, $metadata->type); |
| 289 | 289 | $this->revertCurrentMetadata(); |
| 290 | 290 | |
| 291 | - if (!$node instanceof \DOMCharacterData) { |
|
| 291 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 292 | 292 | 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))); |
| 293 | 293 | } |
| 294 | 294 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if ($metadata->xmlAttributeMap) { |
| 301 | - if (!\is_array($v)) { |
|
| 301 | + if ( ! \is_array($v)) { |
|
| 302 | 302 | throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', \gettype($v))); |
| 303 | 303 | } |
| 304 | 304 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | $node = $this->navigator->accept($value, null); |
| 308 | 308 | $this->revertCurrentMetadata(); |
| 309 | 309 | |
| 310 | - if (!$node instanceof \DOMCharacterData) { |
|
| 310 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 311 | 311 | throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v))); |
| 312 | 312 | } |
| 313 | 313 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | return; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { |
|
| 320 | + if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) { |
|
| 321 | 321 | $namespace = null !== $metadata->xmlNamespace |
| 322 | 322 | ? $metadata->xmlNamespace |
| 323 | 323 | : $this->getClassDefaultNamespace($this->objectMetadataStack->top()); |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | private function isSkippableEmptyObject(?\DOMElement $node, PropertyMetadata $metadata): bool |
| 364 | 364 | { |
| 365 | - return null === $node && !$metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 365 | + return null === $node && ! $metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | private function isSkippableCollection(PropertyMetadata $metadata): bool |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | private function isElementEmpty(\DOMElement $element): bool |
| 374 | 374 | { |
| 375 | - return !$element->hasChildNodes() && !$element->hasAttributes(); |
|
| 375 | + return ! $element->hasChildNodes() && ! $element->hasAttributes(); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | public function endVisitingObject(ClassMetadata $metadata, object $data, array $type): void |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | foreach ($metadata->xmlNamespaces as $prefix => $uri) { |
| 477 | 477 | $attribute = 'xmlns'; |
| 478 | 478 | if ('' !== $prefix) { |
| 479 | - $attribute .= ':' . $prefix; |
|
| 479 | + $attribute .= ':'.$prefix; |
|
| 480 | 480 | } elseif ($element->namespaceURI === $uri) { |
| 481 | 481 | continue; |
| 482 | 482 | } |
@@ -506,21 +506,21 @@ discard block |
||
| 506 | 506 | return $this->document->createElementNS($namespace, $tagName); |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 510 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 509 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 510 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
| 513 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | private function setAttributeOnNode(\DOMElement $node, string $name, string $value, ?string $namespace = null): void |
| 517 | 517 | { |
| 518 | 518 | if (null !== $namespace) { |
| 519 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
| 520 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 519 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
| 520 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $node->setAttributeNS($namespace, $prefix . ':' . $name, $value); |
|
| 523 | + $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
|
| 524 | 524 | } else { |
| 525 | 525 | $node->setAttribute($name, $value); |
| 526 | 526 | } |