@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | if (false !== stripos($data, '<!doctype')) { |
| 69 | 69 | $internalSubset = $this->getDomDocumentTypeEntitySubset($data); |
| 70 | - if (!in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
| 70 | + if ( ! in_array($internalSubset, $this->doctypeWhitelist, true)) { |
|
| 71 | 71 | throw new InvalidArgumentException(sprintf( |
| 72 | 72 | 'The document type "%s" is not allowed. If it is safe, you may add it to the whitelist configuration.', |
| 73 | 73 | $internalSubset |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | private function emptyStringToSpaceCharacter($data) |
| 91 | 91 | { |
| 92 | - return $data === '' ? ' ' : (string)$data; |
|
| 92 | + return $data === '' ? ' ' : (string) $data; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | public function visitNull($data, array $type, Context $context) |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | public function visitString($data, array $type, Context $context) |
| 101 | 101 | { |
| 102 | - $data = (string)$data; |
|
| 102 | + $data = (string) $data; |
|
| 103 | 103 | |
| 104 | 104 | if (null === $this->result) { |
| 105 | 105 | $this->result = $data; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | public function visitBoolean($data, array $type, Context $context) |
| 112 | 112 | { |
| 113 | - $data = (string)$data; |
|
| 113 | + $data = (string) $data; |
|
| 114 | 114 | |
| 115 | 115 | if ('true' === $data || '1' === $data) { |
| 116 | 116 | $data = true; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | public function visitInteger($data, array $type, Context $context) |
| 131 | 131 | { |
| 132 | - $data = (integer)$data; |
|
| 132 | + $data = (integer) $data; |
|
| 133 | 133 | |
| 134 | 134 | if (null === $this->result) { |
| 135 | 135 | $this->result = $data; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | public function visitDouble($data, array $type, Context $context) |
| 142 | 142 | { |
| 143 | - $data = (double)$data; |
|
| 143 | + $data = (double) $data; |
|
| 144 | 144 | |
| 145 | 145 | if (null === $this->result) { |
| 146 | 146 | $this->result = $data; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $nodes = $data->xpath($entryName); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if (!count($nodes)) { |
|
| 170 | + if ( ! count($nodes)) { |
|
| 171 | 171 | if (null === $this->result) { |
| 172 | 172 | return $this->result = array(); |
| 173 | 173 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $nodes = $data->children($namespace)->$entryName; |
| 207 | 207 | foreach ($nodes as $v) { |
| 208 | 208 | $attrs = $v->attributes(); |
| 209 | - if (!isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
| 209 | + if ( ! isset($attrs[$this->currentMetadata->xmlKeyAttribute])) { |
|
| 210 | 210 | throw new RuntimeException(sprintf('The key attribute "%s" must be set for each entry of the map.', $this->currentMetadata->xmlKeyAttribute)); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | $name = $this->advancedNamingStrategy->translateName($metadata, $context); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - if (!$metadata->type) { |
|
| 240 | + if ( ! $metadata->type) { |
|
| 241 | 241 | throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name)); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | if ($metadata->xmlCollection) { |
| 263 | 263 | $enclosingElem = $data; |
| 264 | - if (!$metadata->xmlCollectionInline) { |
|
| 264 | + if ( ! $metadata->xmlCollectionInline) { |
|
| 265 | 265 | $enclosingElem = $data->children($metadata->xmlNamespace)->$name; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | if ($metadata->xmlNamespace) { |
| 277 | 277 | $node = $data->children($metadata->xmlNamespace)->$name; |
| 278 | - if (!$node->count()) { |
|
| 278 | + if ( ! $node->count()) { |
|
| 279 | 279 | return; |
| 280 | 280 | } |
| 281 | 281 | } else { |
@@ -285,9 +285,9 @@ discard block |
||
| 285 | 285 | if (isset($namespaces[''])) { |
| 286 | 286 | $prefix = uniqid('ns-'); |
| 287 | 287 | $data->registerXPathNamespace($prefix, $namespaces['']); |
| 288 | - $nodes = $data->xpath('./' . $prefix . ':' . $name); |
|
| 288 | + $nodes = $data->xpath('./'.$prefix.':'.$name); |
|
| 289 | 289 | } else { |
| 290 | - $nodes = $data->xpath('./' . $name); |
|
| 290 | + $nodes = $data->xpath('./'.$name); |
|
| 291 | 291 | } |
| 292 | 292 | if (empty($nodes)) { |
| 293 | 293 | return; |
@@ -128,24 +128,24 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | if (null === $this->document) { |
| 130 | 130 | $this->document = $this->createDocument(null, null, true); |
| 131 | - $this->currentNode->appendChild($doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string)$data)); |
|
| 131 | + $this->currentNode->appendChild($doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string) $data)); |
|
| 132 | 132 | |
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string)$data); |
|
| 136 | + return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string) $data); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | public function visitSimpleString($data, array $type, Context $context) |
| 140 | 140 | { |
| 141 | 141 | if (null === $this->document) { |
| 142 | 142 | $this->document = $this->createDocument(null, null, true); |
| 143 | - $this->currentNode->appendChild($this->document->createTextNode((string)$data)); |
|
| 143 | + $this->currentNode->appendChild($this->document->createTextNode((string) $data)); |
|
| 144 | 144 | |
| 145 | 145 | return; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - return $this->document->createTextNode((string)$data); |
|
| 148 | + return $this->document->createTextNode((string) $data); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | public function visitBoolean($data, array $type, Context $context) |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $this->setCurrentNode($entryNode); |
| 194 | 194 | |
| 195 | 195 | if (null !== $keyAttributeName) { |
| 196 | - $entryNode->setAttribute($keyAttributeName, (string)$k); |
|
| 196 | + $entryNode->setAttribute($keyAttributeName, (string) $k); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | if (null !== $node = $this->navigator->accept($v, $this->getElementType($type), $context)) { |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $node = $this->navigator->accept($v, $metadata->type, $context); |
| 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 | $attributeName = $this->namingStrategy->translateName($metadata); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | if (($metadata->xmlValue && $this->currentNode->childNodes->length > 0) |
| 261 | - || (!$metadata->xmlValue && $this->hasValue) |
|
| 261 | + || ( ! $metadata->xmlValue && $this->hasValue) |
|
| 262 | 262 | ) { |
| 263 | 263 | 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)); |
| 264 | 264 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $node = $this->navigator->accept($v, $metadata->type, $context); |
| 271 | 271 | $this->revertCurrentMetadata(); |
| 272 | 272 | |
| 273 | - if (!$node instanceof \DOMCharacterData) { |
|
| 273 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 274 | 274 | 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))); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | if ($metadata->xmlAttributeMap) { |
| 283 | - if (!is_array($v)) { |
|
| 283 | + if ( ! is_array($v)) { |
|
| 284 | 284 | throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', gettype($v))); |
| 285 | 285 | } |
| 286 | 286 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $node = $this->navigator->accept($value, null, $context); |
| 290 | 290 | $this->revertCurrentMetadata(); |
| 291 | 291 | |
| 292 | - if (!$node instanceof \DOMCharacterData) { |
|
| 292 | + if ( ! $node instanceof \DOMCharacterData) { |
|
| 293 | 293 | throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v))); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | return; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) { |
|
| 302 | + if ($addEnclosingElement = ! $this->isInLineCollection($metadata) && ! $metadata->inline) { |
|
| 303 | 303 | $elementName = $this->namingStrategy->translateName($metadata); |
| 304 | 304 | if ($this->hasAdvancedNamingStrategy()) { |
| 305 | 305 | $elementName = $this->advancedNamingStrategy->translateName($metadata, $context); |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | private function isSkippableEmptyObject($node, PropertyMetadata $metadata) |
| 347 | 347 | { |
| 348 | - return $node === null && !$metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 348 | + return $node === null && ! $metadata->xmlCollection && $metadata->skipWhenEmpty; |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | private function isSkippableCollection(PropertyMetadata $metadata) |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | private function isElementEmpty(\DOMElement $element) |
| 357 | 357 | { |
| 358 | - return !$element->hasChildNodes() && !$element->hasAttributes(); |
|
| 358 | + return ! $element->hasChildNodes() && ! $element->hasAttributes(); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context) |
@@ -434,12 +434,12 @@ discard block |
||
| 434 | 434 | { |
| 435 | 435 | if (null === $this->document) { |
| 436 | 436 | $this->document = $this->createDocument(null, null, true); |
| 437 | - $this->currentNode->appendChild($textNode = $this->document->createTextNode((string)$data)); |
|
| 437 | + $this->currentNode->appendChild($textNode = $this->document->createTextNode((string) $data)); |
|
| 438 | 438 | |
| 439 | 439 | return $textNode; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - return $this->document->createTextNode((string)$data); |
|
| 442 | + return $this->document->createTextNode((string) $data); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | private function attachNullNamespace() |
| 458 | 458 | { |
| 459 | - if (!$this->nullWasVisited) { |
|
| 459 | + if ( ! $this->nullWasVisited) { |
|
| 460 | 460 | $this->document->documentElement->setAttributeNS( |
| 461 | 461 | 'http://www.w3.org/2000/xmlns/', |
| 462 | 462 | 'xmlns:xsi', |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | foreach ($metadata->xmlNamespaces as $prefix => $uri) { |
| 478 | 478 | $attribute = 'xmlns'; |
| 479 | 479 | if ($prefix !== '') { |
| 480 | - $attribute .= ':' . $prefix; |
|
| 480 | + $attribute .= ':'.$prefix; |
|
| 481 | 481 | } elseif ($element->namespaceURI === $uri) { |
| 482 | 482 | continue; |
| 483 | 483 | } |
@@ -493,19 +493,19 @@ discard block |
||
| 493 | 493 | if ($this->currentNode->isDefaultNamespace($namespace)) { |
| 494 | 494 | return $this->document->createElementNS($namespace, $tagName); |
| 495 | 495 | } |
| 496 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 497 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 496 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
| 497 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 498 | 498 | } |
| 499 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
| 499 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null) |
| 503 | 503 | { |
| 504 | 504 | if (null !== $namespace) { |
| 505 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
| 506 | - $prefix = 'ns-' . substr(sha1($namespace), 0, 8); |
|
| 505 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
| 506 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
| 507 | 507 | } |
| 508 | - $node->setAttributeNS($namespace, $prefix . ':' . $name, $value); |
|
| 508 | + $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
|
| 509 | 509 | } else { |
| 510 | 510 | $node->setAttribute($name, $value); |
| 511 | 511 | } |
@@ -529,6 +529,6 @@ discard block |
||
| 529 | 529 | */ |
| 530 | 530 | public function setFormatOutput($formatOutput) |
| 531 | 531 | { |
| 532 | - $this->formatOutput = (boolean)$formatOutput; |
|
| 532 | + $this->formatOutput = (boolean) $formatOutput; |
|
| 533 | 533 | } |
| 534 | 534 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $isHash = isset($type['params'][1]); |
| 89 | 89 | |
| 90 | 90 | $count = $this->writer->changeCount; |
| 91 | - $isList = (isset($type['params'][0]) && !isset($type['params'][1])) |
|
| 91 | + $isList = (isset($type['params'][0]) && ! isset($type['params'][1])) |
|
| 92 | 92 | || array_keys($data) === range(0, count($data) - 1); |
| 93 | 93 | |
| 94 | 94 | foreach ($data as $k => $v) { |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ($isList && !$isHash) { |
|
| 99 | + if ($isList && ! $isHash) { |
|
| 100 | 100 | $this->writer->writeln('-'); |
| 101 | 101 | } else { |
| 102 | - $this->writer->writeln(Inline::dump($k) . ':'); |
|
| 102 | + $this->writer->writeln(Inline::dump($k).':'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $this->writer->indent(); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | if (null !== $v = $this->navigator->accept($v, $this->getElementType($type), $context)) { |
| 108 | 108 | $this->writer |
| 109 | 109 | ->rtrim(false) |
| 110 | - ->writeln(' ' . $v); |
|
| 110 | + ->writeln(' '.$v); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $this->writer->outdent(); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | public function visitDouble($data, array $type, Context $context) |
| 139 | 139 | { |
| 140 | - $v = (string)$data; |
|
| 140 | + $v = (string) $data; |
|
| 141 | 141 | |
| 142 | 142 | if ('' === $this->writer->content) { |
| 143 | 143 | $this->writer->writeln($v); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | public function visitInteger($data, array $type, Context $context) |
| 150 | 150 | { |
| 151 | - $v = (string)$data; |
|
| 151 | + $v = (string) $data; |
|
| 152 | 152 | |
| 153 | 153 | if ('' === $this->writer->content) { |
| 154 | 154 | $this->writer->writeln($v); |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | $name = $this->advancedNamingStrategy->translateName($metadata, $context); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if (!$metadata->inline) { |
|
| 177 | + if ( ! $metadata->inline) { |
|
| 178 | 178 | $this->writer |
| 179 | - ->writeln(Inline::dump($name) . ':') |
|
| 179 | + ->writeln(Inline::dump($name).':') |
|
| 180 | 180 | ->indent(); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | if (null !== $v = $this->navigator->accept($v, $metadata->type, $context)) { |
| 188 | 188 | $this->writer |
| 189 | 189 | ->rtrim(false) |
| 190 | - ->writeln(' ' . $v); |
|
| 191 | - } elseif ($count === $this->writer->changeCount && !$metadata->inline) { |
|
| 190 | + ->writeln(' '.$v); |
|
| 191 | + } elseif ($count === $this->writer->changeCount && ! $metadata->inline) { |
|
| 192 | 192 | $this->writer->revert(); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if (!$metadata->inline) { |
|
| 195 | + if ( ! $metadata->inline) { |
|
| 196 | 196 | $this->writer->outdent(); |
| 197 | 197 | } |
| 198 | 198 | $this->revertCurrentMetadata(); |