@@ -33,7 +33,7 @@ |
||
| 33 | 33 | |
| 34 | 34 | public function __construct(array $values) |
| 35 | 35 | { |
| 36 | - if (!is_string($values['value'])) { |
|
| 36 | + if ( ! is_string($values['value'])) { |
|
| 37 | 37 | throw new RuntimeException('"value" must be a string.'); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function __construct(array $values) |
| 32 | 32 | { |
| 33 | - if (!isset($values['value']) || !is_string($values['value'])) { |
|
| 33 | + if ( ! isset($values['value']) || ! is_string($values['value'])) { |
|
| 34 | 34 | throw new RuntimeException(sprintf('"value" must be a string.')); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | // Locate possible ObjectManager |
| 50 | 50 | $objectManager = $this->managerRegistry->getManagerForClass($metadata->name); |
| 51 | 51 | |
| 52 | - if (!$objectManager) { |
|
| 52 | + if ( ! $objectManager) { |
|
| 53 | 53 | // No ObjectManager found, proceed with normal deserialization |
| 54 | 54 | return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context); |
| 55 | 55 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Managed entity, check for proxy load |
| 66 | - if (!is_array($data)) { |
|
| 66 | + if ( ! is_array($data)) { |
|
| 67 | 67 | // Single identifier, load proxy |
| 68 | 68 | return $objectManager->getReference($metadata->name, $data); |
| 69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $dataName = $name; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (!array_key_exists($dataName, $data)) { |
|
| 82 | + if ( ! array_key_exists($dataName, $data)) { |
|
| 83 | 83 | return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context); |
| 84 | 84 | } |
| 85 | 85 | $identifierList[$name] = $data[$dataName]; |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | public function createDriver(array $metadataDirs, Reader $reader): DriverInterface |
| 22 | 22 | { |
| 23 | 23 | $driver = call_user_func($this->callback, $metadataDirs, $reader); |
| 24 | - if (!$driver instanceof DriverInterface) { |
|
| 24 | + if ( ! $driver instanceof DriverInterface) { |
|
| 25 | 25 | throw new LogicException('The callback must return an instance of DriverInterface.'); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function startVisiting($object): void |
| 38 | 38 | { |
| 39 | - if (!is_object($object)) { |
|
| 39 | + if ( ! is_object($object)) { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | $this->visitingSet->attach($object); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function stopVisiting($object): void |
| 47 | 47 | { |
| 48 | - if (!is_object($object)) { |
|
| 48 | + if ( ! is_object($object)) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | $this->visitingSet->detach($object); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public function isVisiting($object): bool |
| 60 | 60 | { |
| 61 | - if (!is_object($object)) { |
|
| 61 | + if ( ! is_object($object)) { |
|
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $path[] = get_class($obj); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if (!$path) { |
|
| 75 | + if ( ! $path) { |
|
| 76 | 76 | return null; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | public function getObject(): ?object |
| 93 | 93 | { |
| 94 | - return !$this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
| 94 | + return ! $this->visitingStack->isEmpty() ? $this->visitingStack->top() : null; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function getVisitingStack() |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | private function getNavigator(int $direction): GraphNavigatorInterface |
| 108 | 108 | { |
| 109 | - if (!isset($this->graphNavigators[$direction])) { |
|
| 109 | + if ( ! isset($this->graphNavigators[$direction])) { |
|
| 110 | 110 | throw new RuntimeException( |
| 111 | 111 | sprintf( |
| 112 | 112 | 'Can not find a graph navigator for the direction "%s".', |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | ? $this->serializationVisitors |
| 125 | 125 | : $this->deserializationVisitors; |
| 126 | 126 | |
| 127 | - if (!isset($factories[$format])) { |
|
| 127 | + if ( ! isset($factories[$format])) { |
|
| 128 | 128 | throw new UnsupportedFormatException( |
| 129 | 129 | sprintf( |
| 130 | 130 | 'The format "%s" is not supported for %s.', |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $result = $this->visit($navigator, $visitor, $context, $data, 'json', $type); |
| 183 | 183 | $result = $this->convertArrayObjects($result); |
| 184 | 184 | |
| 185 | - if (!is_array($result)) { |
|
| 185 | + if ( ! is_array($result)) { |
|
| 186 | 186 | throw new RuntimeException(sprintf( |
| 187 | 187 | 'The input data of type "%s" did not convert to an array, but got a result of type "%s".', |
| 188 | 188 | is_object($data) ? get_class($data) : gettype($data), |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function createRoot(?ClassMetadata $metadata = null, ?string $rootName = null, ?string $rootNamespace = null, ?string $rootPrefix = null) |
| 74 | 74 | { |
| 75 | - if ($metadata !== null && !empty($metadata->xmlRootName)) { |
|
| 75 | + if ($metadata !== null && ! empty($metadata->xmlRootName)) { |
|
| 76 | 76 | $rootPrefix = $metadata->xmlRootPrefix; |
| 77 | 77 | $rootName = $metadata->xmlRootName; |
| 78 | 78 | $rootNamespace = $metadata->xmlRootNamespace ?: $this->getClassDefaultNamespace($metadata); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $document = $this->getDocument(); |
| 86 | 86 | if ($rootNamespace) { |
| 87 | - $rootNode = $document->createElementNS($rootNamespace, ($rootPrefix !== null ? ($rootPrefix . ':') : '') . $rootName); |
|
| 87 | + $rootNode = $document->createElementNS($rootNamespace, ($rootPrefix !== null ? ($rootPrefix.':') : '').$rootName); |
|
| 88 | 88 | } else { |
| 89 | 89 | $rootNode = $document->createElement($rootName); |
| 90 | 90 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | public function visitDouble(float $data, array $type) |
| 129 | 129 | { |
| 130 | 130 | if (floor($data) === $data) { |
| 131 | - return $this->document->createTextNode($data . '.0'); |
|
| 131 | + return $this->document->createTextNode($data.'.0'); |
|
| 132 | 132 | } else { |
| 133 | 133 | return $this->document->createTextNode((string) $data); |
| 134 | 134 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $node = $this->navigator->accept($v, $metadata->type); |
| 189 | 189 | $this->revertCurrentMetadata(); |
| 190 | 190 | |
| 191 | - if (!$node instanceof \DOMCharacterData) { |
|
| 191 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 192 | 192 | throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v))); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | if (($metadata->xmlValue && $this->currentNode->childNodes->length > 0) |
| 201 | - || (!$metadata->xmlValue && $this->hasValue) |
|
| 201 | + || ( ! $metadata->xmlValue && $this->hasValue) |
|
| 202 | 202 | ) { |
| 203 | 203 | 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)); |
| 204 | 204 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $node = $this->navigator->accept($v, $metadata->type); |
| 211 | 211 | $this->revertCurrentMetadata(); |
| 212 | 212 | |
| 213 | - if (!$node instanceof \DOMCharacterData) { |
|
| 213 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 214 | 214 | 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))); |
| 215 | 215 | } |
| 216 | 216 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | if ($metadata->xmlAttributeMap) { |
| 223 | - if (!is_array($v)) { |
|
| 223 | + if ( ! is_array($v)) { |
|
| 224 | 224 | throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', gettype($v))); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $node = $this->navigator->accept($value, null); |
| 230 | 230 | $this->revertCurrentMetadata(); |
| 231 | 231 | |
| 232 | - if (!$node instanceof \DOMCharacterData) { |
|
| 232 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 233 | 233 | throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v))); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | return; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { |
|
| 242 | + if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) { |
|
| 243 | 243 | $namespace = null !== $metadata->xmlNamespace |
| 244 | 244 | ? $metadata->xmlNamespace |
| 245 | 245 | : $this->getClassDefaultNamespace($this->objectMetadataStack->top()); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | private function isSkippableEmptyObject($node, PropertyMetadata $metadata) |
| 285 | 285 | { |
| 286 | - return $node === null && !$metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 286 | + return $node === null && ! $metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | private function isSkippableCollection(PropertyMetadata $metadata) |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | private function isElementEmpty(\DOMElement $element) |
| 295 | 295 | { |
| 296 | - return !$element->hasChildNodes() && !$element->hasAttributes(); |
|
| 296 | + return ! $element->hasChildNodes() && ! $element->hasAttributes(); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | public function endVisitingObject(ClassMetadata $metadata, object $data, array $type): void |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | foreach ($metadata->xmlNamespaces as $prefix => $uri) { |
| 397 | 397 | $attribute = 'xmlns'; |
| 398 | 398 | if ($prefix !== '') { |
| 399 | - $attribute .= ':' . $prefix; |
|
| 399 | + $attribute .= ':'.$prefix; |
|
| 400 | 400 | } elseif ($element->namespaceURI === $uri) { |
| 401 | 401 | continue; |
| 402 | 402 | } |
@@ -412,19 +412,19 @@ discard block |
||
| 412 | 412 | if ($this->currentNode->isDefaultNamespace($namespace)) { |
| 413 | 413 | return $this->document->createElementNS($namespace, $tagName); |
| 414 | 414 | } |
| 415 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 416 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 415 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 416 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 417 | 417 | } |
| 418 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
| 418 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null): void |
| 422 | 422 | { |
| 423 | 423 | if (null !== $namespace) { |
| 424 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
| 425 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 424 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
| 425 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 426 | 426 | } |
| 427 | - $node->setAttributeNS($namespace, $prefix . ':' . $name, $value); |
|
| 427 | + $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
|
| 428 | 428 | } else { |
| 429 | 429 | $node->setAttribute($name, $value); |
| 430 | 430 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | if (false !== stripos($data, '<!doctype')) { |
| 62 | 62 | $internalSubset = $this->getDomDocumentTypeEntitySubset($data); |
| 63 | - if (!in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
| 63 | + if ( ! in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
| 64 | 64 | throw new InvalidArgumentException(sprintf( |
| 65 | 65 | 'The document type "%s" is not allowed. If it is safe, you may add it to the whitelist configuration.', |
| 66 | 66 | $internalSubset |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $nodes = $data->xpath($entryName); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if (!count($nodes)) { |
|
| 162 | + if ( ! count($nodes)) { |
|
| 163 | 163 | return []; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $nodes = $data->children($namespace)->$entryName; |
| 188 | 188 | foreach ($nodes as $v) { |
| 189 | 189 | $attrs = $v->attributes(); |
| 190 | - if (!isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
| 190 | + if ( ! isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
| 191 | 191 | throw new RuntimeException(sprintf('The key attribute "%s" must be set for each entry of the map.', $this->currentMetadata->xmlKeyAttribute)); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | return (string) $data->attributes($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}; |
| 215 | 215 | |
| 216 | 216 | // Check XML element with namespace for discriminatorFieldName |
| 217 | - case !$metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}): |
|
| 217 | + case ! $metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}): |
|
| 218 | 218 | return (string) $data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}; |
| 219 | 219 | // Check XML element for discriminatorFieldName |
| 220 | 220 | case isset($data->{$metadata->discriminatorFieldName}): |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | { |
| 240 | 240 | $name = $metadata->serializedName; |
| 241 | 241 | |
| 242 | - if (!$metadata->type) { |
|
| 242 | + if ( ! $metadata->type) { |
|
| 243 | 243 | throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->class, $metadata->name)); |
| 244 | 244 | } |
| 245 | 245 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | if ($metadata->xmlCollection) { |
| 260 | 260 | $enclosingElem = $data; |
| 261 | - if (!$metadata->xmlCollectionInline) { |
|
| 261 | + if ( ! $metadata->xmlCollectionInline) { |
|
| 262 | 262 | $enclosingElem = $data->children($metadata->xmlNamespace)->$name; |
| 263 | 263 | } |
| 264 | 264 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | if ($metadata->xmlNamespace) { |
| 272 | 272 | $node = $data->children($metadata->xmlNamespace)->$name; |
| 273 | - if (!$node->count()) { |
|
| 273 | + if ( ! $node->count()) { |
|
| 274 | 274 | throw new NotAcceptableException(); |
| 275 | 275 | } |
| 276 | 276 | } else { |
@@ -279,9 +279,9 @@ discard block |
||
| 279 | 279 | if (isset($namespaces[''])) { |
| 280 | 280 | $prefix = uniqid('ns-'); |
| 281 | 281 | $data->registerXPathNamespace($prefix, $namespaces['']); |
| 282 | - $nodes = $data->xpath('./' . $prefix . ':' . $name); |
|
| 282 | + $nodes = $data->xpath('./'.$prefix.':'.$name); |
|
| 283 | 283 | } else { |
| 284 | - $nodes = $data->xpath('./' . $name); |
|
| 284 | + $nodes = $data->xpath('./'.$name); |
|
| 285 | 285 | } |
| 286 | 286 | if (empty($nodes)) { |
| 287 | 287 | throw new NotAcceptableException(); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | switch ($type['name']) { |
| 116 | 116 | case 'NULL': |
| 117 | - if (!$this->shouldSerializeNull) { |
|
| 117 | + if ( ! $this->shouldSerializeNull) { |
|
| 118 | 118 | throw new NotAcceptableException(); |
| 119 | 119 | } |
| 120 | 120 | return $this->visitor->visitNull($data, $type); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | case 'resource': |
| 141 | 141 | $msg = 'Resources are not supported in serialized data.'; |
| 142 | 142 | if (null !== $path = $this->context->getPath()) { |
| 143 | - $msg .= ' Path: ' . $path; |
|
| 143 | + $msg .= ' Path: '.$path; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | throw new RuntimeException($msg); |