Passed
Push — master ( 844759...f0c5ab )
by stéphane
07:52
created
sources/Yaml.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,9 @@
 block discarded – undo
111 111
     }
112 112
     foreach ($comparison as $className) {
113 113
         $fqn = __NAMESPACE__."\\$className";
114
-        if ($obj instanceof $fqn) return true;
114
+        if ($obj instanceof $fqn) {
115
+            return true;
116
+        }
115 117
     }
116 118
     return false;
117 119
 }
118 120
\ No newline at end of file
Please login to merge, or discard this patch.
sources/Loader.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,7 +93,9 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $source = $this->content ?? preg_split("/\n/m", preg_replace('/(\r\n|\r)/', "\n", $strContent), 0, PREG_SPLIT_DELIM_CAPTURE);
95 95
         //TODO : be more permissive on $strContent values
96
-        if (!is_array($source) || !count($source)) throw new \Exception(self::EXCEPTION_LINE_SPLIT);
96
+        if (!is_array($source) || !count($source)) {
97
+            throw new \Exception(self::EXCEPTION_LINE_SPLIT);
98
+        }
97 99
         foreach ($source as $key => $value) {
98 100
             yield ++$key => $value;
99 101
         }
@@ -116,7 +118,9 @@  discard block
 block discarded – undo
116 118
         try {
117 119
             foreach ($generator as $lineNb => $lineString) {
118 120
                 $node = NodeFactory::get($lineString, $lineNb);
119
-                if ($this->needsSpecialProcess($node, $previous)) continue;
121
+                if ($this->needsSpecialProcess($node, $previous)) {
122
+                    continue;
123
+                }
120 124
                 $this->attachBlankLines($previous);
121 125
                 switch ($node->indent <=> $previous->indent) {
122 126
                     case -1: $target = $previous->getTargetOnLessIndent($node);
Please login to merge, or discard this patch.
sources/NodeList.php 1 patch
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
         $tmp->rewind();
36 36
         $fqn = __NAMESPACE__."\\$nodeType";
37 37
         foreach ($tmp as $child) {
38
-            if ($child instanceof $fqn) return true;
38
+            if ($child instanceof $fqn) {
39
+                return true;
40
+            }
39 41
         }
40 42
         return false;
41 43
     }
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
         foreach ($tmp as $child) {
48 50
             if (!($child instanceof NodeComment)
49 51
                 && !($child instanceof NodeDirective)
50
-                && !($child instanceof NodeDocstart && is_null($child->value)) ) return true;
52
+                && !($child instanceof NodeDocstart && is_null($child->value)) ) {
53
+                return true;
54
+            }
51 55
         }
52 56
         return false;
53 57
     }
@@ -55,9 +59,11 @@  discard block
 block discarded – undo
55 59
     public function push($node)
56 60
     {
57 61
         $type = null;
58
-        if     ($node instanceof NodeItem )    $type = self::SEQUENCE;
59
-        elseif ($node instanceof NodeKey)      $type = self::MAPPING;
60
-        elseif ($node instanceof NodeSetKey
62
+        if     ($node instanceof NodeItem ) {
63
+            $type = self::SEQUENCE;
64
+        } elseif ($node instanceof NodeKey) {
65
+            $type = self::MAPPING;
66
+        } elseif ($node instanceof NodeSetKey
61 67
              || $node instanceof NodeSetValue) {
62 68
             $type = self::SET;
63 69
         } elseif ($node instanceof NodeScalar ){
Please login to merge, or discard this patch.
sources/nodes/NodeLiterals.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@
 block discarded – undo
23 23
 
24 24
     public function add(Node $child):Node
25 25
     {
26
-        if (is_null($this->value)) $this->value = new NodeList();
26
+        if (is_null($this->value)) {
27
+            $this->value = new NodeList();
28
+        }
27 29
         $candidate = $child;
28 30
         if (!isOneOf($child, ['NodeScalar', 'NodeBlank', 'NodeComment', 'NodeQuoted'])) {
29 31
             $candidate = new NodeScalar($child->raw, $child->line);
Please login to merge, or discard this patch.
sources/nodes/NodeSetKey.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@
 block discarded – undo
31 31
         $built = is_null($this->value) ? null : $this->value->build();
32 32
         $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" '): $built;
33 33
         $key = json_encode($stringKey, JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES);
34
-        if (empty($key)) throw new \Exception("Cant serialize complex key: ".var_export($this->value, true));
34
+        if (empty($key)) {
35
+            throw new \Exception("Cant serialize complex key: ".var_export($this->value, true));
36
+        }
35 37
         $parent->{trim($key, '\'" ')} = null;
36 38
     }
37 39
 
Please login to merge, or discard this patch.
sources/Node.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,7 +65,9 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function getParent(int $indent = null):Node
67 67
     {
68
-        if (!is_int($indent)) return $this->_parent;
68
+        if (!is_int($indent)) {
69
+            return $this->_parent;
70
+        }
69 71
         $cursor = $this->getParent();
70 72
         while (!($cursor instanceof NodeRoot)
71 73
                 && (is_null($cursor->indent)
@@ -200,13 +202,23 @@  discard block
 block discarded – undo
200 202
     {
201 203
         $props = [];
202 204
         $props['line->indent'] = "$this->line -> $this->indent";
203
-        if ($this->identifier) $props['identifier'] = "($this->identifier)";
204
-        if ($this->_anchor)    $props['_anchor']    = "($this->_anchor)";
205
-        if ($this->_tag)       $props['_tag']       = "($this->_tag)";
206
-        if ($this->value)      $props['value']       = $this->value;
205
+        if ($this->identifier) {
206
+            $props['identifier'] = "($this->identifier)";
207
+        }
208
+        if ($this->_anchor) {
209
+            $props['_anchor']    = "($this->_anchor)";
210
+        }
211
+        if ($this->_tag) {
212
+            $props['_tag']       = "($this->_tag)";
213
+        }
214
+        if ($this->value) {
215
+            $props['value']       = $this->value;
216
+        }
207 217
         // $props['value'] = $this->value;
208 218
         $props['raw']   = $this->raw;
209
-        if (!$this->_parent)  $props['parent'] = 'NO PARENT!!!';
219
+        if (!$this->_parent) {
220
+            $props['parent'] = 'NO PARENT!!!';
221
+        }
210 222
         return $props;
211 223
     }
212 224
 }
Please login to merge, or discard this patch.
sources/NodeFactory.php 1 patch
Braces   +19 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,10 +16,13 @@  discard block
 block discarded – undo
16 16
     final public static function get($nodeString = null, $line = 0):Node
17 17
     {
18 18
         $trimmed = ltrim($nodeString);
19
-        if ($trimmed === '')                                return new NodeBlank($nodeString, $line);
20
-        elseif (substr($trimmed, 0, 3) === '...')           return new NodeDocEnd($nodeString, $line);
21
-        elseif (preg_match(Regex::KEY, $trimmed, $matches)) return new NodeKey($nodeString, $line, $matches);
22
-        else {
19
+        if ($trimmed === '') {
20
+            return new NodeBlank($nodeString, $line);
21
+        } elseif (substr($trimmed, 0, 3) === '...') {
22
+            return new NodeDocEnd($nodeString, $line);
23
+        } elseif (preg_match(Regex::KEY, $trimmed, $matches)) {
24
+            return new NodeKey($nodeString, $line, $matches);
25
+        } else {
23 26
             $first = $trimmed[0];
24 27
             $stringGroups = ["-" ,'>|' ,'"\'',"#%" ,"{[" ,":?" ,'*&!'];
25 28
             $methodGroups = ['Hyphen','Literal','Quoted','Special','Compact','SetElement','NodeAction'];
@@ -90,10 +93,13 @@  discard block
 block discarded – undo
90 93
     final private static function onCompact(string $first, string $nodeString, int $line):Node
91 94
     {
92 95
         $json = json_decode($nodeString, false, 512, self::JSON_OPTIONS);
93
-        if (json_last_error() === \JSON_ERROR_NONE)             return new NodeJSON($nodeString, $line);
94
-        elseif (preg_match(Regex::MAPPING, trim($nodeString)))  return new NodeCompactMapping($nodeString, $line);
95
-        elseif (preg_match(Regex::SEQUENCE, trim($nodeString))) return new NodeCompactSequence($nodeString, $line);
96
-        else {
96
+        if (json_last_error() === \JSON_ERROR_NONE) {
97
+            return new NodeJSON($nodeString, $line);
98
+        } elseif (preg_match(Regex::MAPPING, trim($nodeString))) {
99
+            return new NodeCompactMapping($nodeString, $line);
100
+        } elseif (preg_match(Regex::SEQUENCE, trim($nodeString))) {
101
+            return new NodeCompactSequence($nodeString, $line);
102
+        } else {
97 103
             return new NodePartial($nodeString, $line);
98 104
         }
99 105
     }
@@ -108,9 +114,11 @@  discard block
 block discarded – undo
108 114
      */
109 115
     final private static function onHyphen(string $first, string $nodeString, int $line):Node
110 116
     {
111
-        if (substr($nodeString, 0, 3) === '---')              return new NodeDocStart($nodeString, $line);
112
-        elseif (preg_match(Regex::ITEM, ltrim($nodeString)))  return new NodeItem($nodeString, $line);
113
-        else {
117
+        if (substr($nodeString, 0, 3) === '---') {
118
+            return new NodeDocStart($nodeString, $line);
119
+        } elseif (preg_match(Regex::ITEM, ltrim($nodeString))) {
120
+            return new NodeItem($nodeString, $line);
121
+        } else {
114 122
             return new NodeScalar($nodeString, $line);
115 123
         }
116 124
     }
Please login to merge, or discard this patch.
sources/types/YamlObject.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,8 +74,12 @@
 block discarded – undo
74 74
     {
75 75
         $prop = get_object_vars($this);
76 76
         unset($prop["__yaml__object__api"]);
77
-        if (count($prop) > 0) return $prop;
78
-        if (count($this) > 0) return iterator_to_array($this);
77
+        if (count($prop) > 0) {
78
+            return $prop;
79
+        }
80
+        if (count($this) > 0) {
81
+            return iterator_to_array($this);
82
+        }
79 83
         return $this->__yaml__object__api->value ?? "_Empty YamlObject_";
80 84
     }
81 85
 }
Please login to merge, or discard this patch.
sources/Builder.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -90,8 +90,12 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public static function getScalar(string $v, bool $onlyScalar = false)
92 92
     {
93
-        if (Regex::isDate($v))   return self::$dateAsObject && !$onlyScalar ? date_create($v) : $v;
94
-        if (Regex::isNumber($v)) return self::getNumber($v);
93
+        if (Regex::isDate($v)) {
94
+            return self::$dateAsObject && !$onlyScalar ? date_create($v) : $v;
95
+        }
96
+        if (Regex::isNumber($v)) {
97
+            return self::getNumber($v);
98
+        }
95 99
         $types = ['yes'   => true,
96 100
                     'no'    => false,
97 101
                     'true'  => true,
@@ -114,8 +118,12 @@  discard block
 block discarded – undo
114 118
      */
115 119
     private static function getNumber(string $v)
116 120
     {
117
-        if (preg_match(Regex::OCTAL_NUM, $v)) return intval(base_convert($v, 8, 10));
118
-        if (preg_match(Regex::HEX_NUM, $v))   return intval(base_convert($v, 16, 10));
121
+        if (preg_match(Regex::OCTAL_NUM, $v)) {
122
+            return intval(base_convert($v, 8, 10));
123
+        }
124
+        if (preg_match(Regex::HEX_NUM, $v)) {
125
+            return intval(base_convert($v, 16, 10));
126
+        }
119 127
         return is_bool(strpos($v, '.')) ? intval($v) : floatval($v);
120 128
     }
121 129
 
Please login to merge, or discard this patch.