Explorar o código

[Seriliazer] [XmlEncoder] Optimize conditions

Joel Wurtz %!s(int64=14) %!d(string=hai) anos
pai
achega
f11cc2de0b
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

+ 4 - 3
src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

@@ -54,9 +54,10 @@ class XmlEncoder extends AbstractEncoder implements DecoderInterface
     public function decode($data, $format)
     {
         $xml = simplexml_load_string($data);
-        if (!$xml->count() && !$xml->attributes()) {
-            return (string) $xml;
-        } elseif (!$xml->count()) {
+        if (!$xml->count()) {
+            if (!$xml->attributes()) {
+                return (string) $xml;
+            }
             $data = array();
             foreach ($xml->attributes() as $attrkey => $attr) {
                 $data['@'.$attrkey] = (string) $attr;