@@ -18,7 +18,6 @@ |
||
18 | 18 | |
19 | 19 | namespace JMS\Serializer; |
20 | 20 | |
21 | -use JMS\Serializer\Exception\LogicException; |
|
22 | 21 | use JMS\Serializer\Exception\RuntimeException; |
23 | 22 | use Metadata\MetadataFactoryInterface; |
24 | 23 |
@@ -166,10 +166,10 @@ |
||
166 | 166 | $parentStr |
167 | 167 | ) = $unserialized; |
168 | 168 | |
169 | - if (isset($unserialized['xmlEntryNamespace'])){ |
|
169 | + if (isset($unserialized['xmlEntryNamespace'])) { |
|
170 | 170 | $this->xmlEntryNamespace = $unserialized['xmlEntryNamespace']; |
171 | 171 | } |
172 | - if (isset($unserialized['xmlCollectionSkipWhenEmpty'])){ |
|
172 | + if (isset($unserialized['xmlCollectionSkipWhenEmpty'])) { |
|
173 | 173 | $this->xmlCollectionSkipWhenEmpty = $unserialized['xmlCollectionSkipWhenEmpty']; |
174 | 174 | } |
175 | 175 |
@@ -166,10 +166,10 @@ |
||
166 | 166 | $parentStr |
167 | 167 | ) = $unserialized; |
168 | 168 | |
169 | - if (isset($unserialized['xmlEntryNamespace'])){ |
|
169 | + if (isset($unserialized['xmlEntryNamespace'])) { |
|
170 | 170 | $this->xmlEntryNamespace = $unserialized['xmlEntryNamespace']; |
171 | 171 | } |
172 | - if (isset($unserialized['xmlCollectionSkipWhenEmpty'])){ |
|
172 | + if (isset($unserialized['xmlCollectionSkipWhenEmpty'])) { |
|
173 | 173 | $this->xmlCollectionSkipWhenEmpty = $unserialized['xmlCollectionSkipWhenEmpty']; |
174 | 174 | } |
175 | 175 |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $this->document = $this->createDocument(null, null, false); |
198 | 198 | if ($metadata->xmlRootName) { |
199 | 199 | $rootName = $metadata->xmlRootName; |
200 | - $rootNamespace = $metadata->xmlRootNamespace?:$this->getClassDefaultNamespace($metadata); |
|
200 | + $rootNamespace = $metadata->xmlRootNamespace ?: $this->getClassDefaultNamespace($metadata); |
|
201 | 201 | } else { |
202 | 202 | $rootName = $this->defaultRootName; |
203 | 203 | $rootNamespace = $this->defaultRootNamespace; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | if ($addEnclosingElement) { |
304 | 304 | $this->revertCurrentNode(); |
305 | 305 | |
306 | - if ($this->nodeNotEmpty($element) || ((!$metadata->xmlCollection || !$metadata->xmlCollectionSkipWhenEmpty) && $node === null && $v !== null && !$context->isVisiting($v))) { |
|
306 | + if ($this->nodeNotEmpty($element) || (( ! $metadata->xmlCollection || ! $metadata->xmlCollectionSkipWhenEmpty) && $node === null && $v !== null && ! $context->isVisiting($v))) { |
|
307 | 307 | $this->currentNode->appendChild($element); |
308 | 308 | } |
309 | 309 | } |
@@ -449,18 +449,18 @@ discard block |
||
449 | 449 | if ($this->currentNode->isDefaultNamespace($namespace)) { |
450 | 450 | return $this->document->createElementNS($namespace, $tagName); |
451 | 451 | } |
452 | - if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) { |
|
453 | - $prefix = 'ns-'. substr(sha1($namespace), 0, 8); |
|
454 | - return $this->document->createElementNS($namespace, $prefix . ':' . $tagName); |
|
452 | + if ( ! ($prefix = $this->currentNode->lookupPrefix($namespace)) && ! ($prefix = $this->document->lookupPrefix($namespace))) { |
|
453 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
454 | + return $this->document->createElementNS($namespace, $prefix.':'.$tagName); |
|
455 | 455 | } |
456 | - return $this->document->createElement($prefix . ':' . $tagName); |
|
456 | + return $this->document->createElement($prefix.':'.$tagName); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null) |
460 | 460 | { |
461 | 461 | if (null !== $namespace) { |
462 | - if (!$prefix = $node->lookupPrefix($namespace)) { |
|
463 | - $prefix = 'ns-'. substr(sha1($namespace), 0, 8); |
|
462 | + if ( ! $prefix = $node->lookupPrefix($namespace)) { |
|
463 | + $prefix = 'ns-'.substr(sha1($namespace), 0, 8); |
|
464 | 464 | } |
465 | 465 | $node->setAttributeNS($namespace, $prefix.':'.$name, $value); |
466 | 466 | } else { |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | |
471 | 471 | private function getClassDefaultNamespace(ClassMetadata $metadata) |
472 | 472 | { |
473 | - return (isset($metadata->xmlNamespaces[''])?$metadata->xmlNamespaces['']:null); |
|
473 | + return (isset($metadata->xmlNamespaces['']) ? $metadata->xmlNamespaces[''] : null); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | } |
@@ -48,12 +48,18 @@ discard block |
||
48 | 48 | private $nullWasVisited; |
49 | 49 | private $objectMetadataStack; |
50 | 50 | |
51 | + /** |
|
52 | + * @param Naming\PropertyNamingStrategyInterface $namingStrategy |
|
53 | + */ |
|
51 | 54 | public function __construct($namingStrategy) |
52 | 55 | { |
53 | 56 | parent::__construct($namingStrategy); |
54 | 57 | $this->objectMetadataStack = new \SplStack; |
55 | 58 | } |
56 | 59 | |
60 | + /** |
|
61 | + * @param Naming\PropertyNamingStrategyInterface $namingStrategy |
|
62 | + */ |
|
57 | 63 | public function __construct($namingStrategy) |
58 | 64 | { |
59 | 65 | parent::__construct($namingStrategy); |
@@ -151,6 +157,9 @@ discard block |
||
151 | 157 | return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string) $data); |
152 | 158 | } |
153 | 159 | |
160 | + /** |
|
161 | + * @param string $data |
|
162 | + */ |
|
154 | 163 | public function visitSimpleString($data, array $type, Context $context) |
155 | 164 | { |
156 | 165 | if (null === $this->document) { |
@@ -468,6 +477,9 @@ discard block |
||
468 | 477 | } |
469 | 478 | } |
470 | 479 | |
480 | + /** |
|
481 | + * @return \DOMNode |
|
482 | + */ |
|
471 | 483 | private function createElement($tagName, $namespace = null) |
472 | 484 | { |
473 | 485 | if (null === $namespace) { |
@@ -483,6 +495,9 @@ discard block |
||
483 | 495 | return $this->document->createElement($prefix . ':' . $tagName); |
484 | 496 | } |
485 | 497 | |
498 | + /** |
|
499 | + * @param string $value |
|
500 | + */ |
|
486 | 501 | private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null) |
487 | 502 | { |
488 | 503 | if (null !== $namespace) { |