Completed
Pull Request — master (#539)
by Delf
03:23
created
src/JMS/Serializer/XmlSerializationVisitor.php 2 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -44,6 +44,9 @@  discard block
 block discarded – undo
44 44
     private $nullWasVisited;
45 45
     private $objectMetadataStack;
46 46
 
47
+    /**
48
+     * @param Naming\PropertyNamingStrategyInterface $namingStrategy
49
+     */
47 50
     public function __construct($namingStrategy)
48 51
     {
49 52
         parent::__construct($namingStrategy);
@@ -126,6 +129,9 @@  discard block
 block discarded – undo
126 129
         return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string) $data);
127 130
     }
128 131
 
132
+    /**
133
+     * @param string $data
134
+     */
129 135
     public function visitSimpleString($data, array $type, Context $context)
130 136
     {
131 137
         if (null === $this->document) {
@@ -437,6 +443,9 @@  discard block
 block discarded – undo
437 443
         }
438 444
     }
439 445
 
446
+    /**
447
+     * @return \DOMNode
448
+     */
440 449
     private function createElement($tagName, $namespace = null)
441 450
     {
442 451
         if (null !== $namespace) {
@@ -456,6 +465,9 @@  discard block
 block discarded – undo
456 465
         }
457 466
     }
458 467
 
468
+    /**
469
+     * @param string $value
470
+     */
459 471
     private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null)
460 472
     {
461 473
         if (null !== $namespace) {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/JMS/Serializer/SerializationContext.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/JMS/Serializer/Metadata/PropertyMetadata.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -168,13 +168,13 @@
 block discarded – undo
168 168
             $parentStr
169 169
         ) = $unserialized;
170 170
 
171
-        if (isset($unserialized['xmlEntryNamespace'])){
171
+        if (isset($unserialized['xmlEntryNamespace'])) {
172 172
             $this->xmlEntryNamespace = $unserialized['xmlEntryNamespace'];
173 173
         }
174
-        if (isset($unserialized['xmlCollectionSkipWhenEmpty'])){
174
+        if (isset($unserialized['xmlCollectionSkipWhenEmpty'])) {
175 175
             $this->xmlCollectionSkipWhenEmpty = $unserialized['xmlCollectionSkipWhenEmpty'];
176 176
         }
177
-        if (isset($unserialized['exclusionGroups'])){
177
+        if (isset($unserialized['exclusionGroups'])) {
178 178
             $this->exclusionGroups = $unserialized['exclusionGroups'];
179 179
         }
180 180
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -168,13 +168,13 @@
 block discarded – undo
168 168
             $parentStr
169 169
         ) = $unserialized;
170 170
 
171
-        if (isset($unserialized['xmlEntryNamespace'])){
171
+        if (isset($unserialized['xmlEntryNamespace'])) {
172 172
             $this->xmlEntryNamespace = $unserialized['xmlEntryNamespace'];
173 173
         }
174
-        if (isset($unserialized['xmlCollectionSkipWhenEmpty'])){
174
+        if (isset($unserialized['xmlCollectionSkipWhenEmpty'])) {
175 175
             $this->xmlCollectionSkipWhenEmpty = $unserialized['xmlCollectionSkipWhenEmpty'];
176 176
         }
177
-        if (isset($unserialized['exclusionGroups'])){
177
+        if (isset($unserialized['exclusionGroups'])) {
178 178
             $this->exclusionGroups = $unserialized['exclusionGroups'];
179 179
         }
180 180
 
Please login to merge, or discard this patch.