Completed
Push — master ( f50740...419cde )
by stéphane
02:30
created
yaml/Builder.php 1 patch
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
 
23 23
     private static function build(object $node, &$parent = null)
24 24
     {
25
-        if ($node instanceof NodeList) return self::buildNodeList($node, $parent);
25
+        if ($node instanceof NodeList) {
26
+            return self::buildNodeList($node, $parent);
27
+        }
26 28
         return self::buildNode($node, $parent);
27 29
     }
28 30
 
@@ -64,12 +66,15 @@  discard block
 block discarded – undo
64 66
             case Y\REF_DEF: //fall through
65 67
             case Y\REF_CALL://TODO: self::build returns what ?
66 68
                 $tmp = is_object($value) ? self::build($value, $parent) : $node->getPhpValue();
67
-                if ($type === Y\REF_DEF) self::$_root->addReference($identifier, $tmp);
69
+                if ($type === Y\REF_DEF) {
70
+                    self::$_root->addReference($identifier, $tmp);
71
+                }
68 72
                 return self::$_root->getReference($identifier);
69 73
             case Y\SET_KEY:
70 74
                 $key = json_encode(self::build($value, $parent), JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES);
71
-                if (empty($key))
72
-                    throw new \Exception("Cant serialize complex key: ".var_export($value, true), 1);
75
+                if (empty($key)) {
76
+                                    throw new \Exception("Cant serialize complex key: ".var_export($value, true), 1);
77
+                }
73 78
                 $parent->{$key} = null;
74 79
                 return;
75 80
             case Y\SET_VALUE:
@@ -88,8 +93,11 @@  discard block
 block discarded – undo
88 93
                     $parent->addTag($identifier); return;
89 94
                 } else {//TODO: have somewhere a list of common tags and their treatment
90 95
                     if (in_array($identifier, ['!binary', '!str'])) {
91
-                        if ($value->value instanceof NodeList) $value->value->type = Y\RAW;
92
-                        else $value->type = Y\RAW;
96
+                        if ($value->value instanceof NodeList) {
97
+                            $value->value->type = Y\RAW;
98
+                        } else {
99
+                            $value->type = Y\RAW;
100
+                        }
93 101
                     }
94 102
                     $val = is_null($value) ? null : self::build(/** @scrutinizer ignore-type */ $value, $node);
95 103
                     return new Tag($identifier, $val);
@@ -158,10 +166,14 @@  discard block
 block discarded – undo
158 166
         }
159 167
         $_root->value->setIteratorMode(NodeList::IT_MODE_DELETE);
160 168
         foreach ($_root->value as $child) {
161
-            if ($child->type & Y\DOC_START) $totalDocStart++;
169
+            if ($child->type & Y\DOC_START) {
170
+                $totalDocStart++;
171
+            }
162 172
             //if 0 or 1 DOC_START = we are still in first document
163 173
             $currentDoc = $totalDocStart > 1 ? $totalDocStart - 1 : 0;
164
-            if (!isset($documents[$currentDoc])) $documents[$currentDoc] = new NodeList();
174
+            if (!isset($documents[$currentDoc])) {
175
+                $documents[$currentDoc] = new NodeList();
176
+            }
165 177
             $documents[$currentDoc]->push($child);
166 178
         }
167 179
         // $_debug >= 2 && var_dump($documents);//var_dump($documents);die("documents");
Please login to merge, or discard this patch.