Completed
Push — master ( c45521...844759 )
by stéphane
08:22
created
sources/NodeFactory.php 1 patch
Braces   +24 added lines, -14 removed lines patch added patch discarded remove patch
@@ -92,10 +92,13 @@  discard block
 block discarded – undo
92 92
     final private static function onCompact(string $nodeString, int $line):Node
93 93
     {
94 94
         $json = json_decode($nodeString, false, 512, self::JSON_OPTIONS);
95
-        if (json_last_error() === \JSON_ERROR_NONE)       return new NodeJSON($nodeString, $line, $json);
96
-        elseif (preg_match(Regex::MAPPING, $nodeString))  return new NodeCompactMapping($nodeString, $line);
97
-        elseif (preg_match(Regex::SEQUENCE, $nodeString)) return new NodeCompactSequence($nodeString, $line);
98
-        else {
95
+        if (json_last_error() === \JSON_ERROR_NONE) {
96
+            return new NodeJSON($nodeString, $line, $json);
97
+        } elseif (preg_match(Regex::MAPPING, $nodeString)) {
98
+            return new NodeCompactMapping($nodeString, $line);
99
+        } elseif (preg_match(Regex::SEQUENCE, $nodeString)) {
100
+            return new NodeCompactSequence($nodeString, $line);
101
+        } else {
99 102
             return new NodePartial($nodeString, $line);
100 103
         }
101 104
     }
@@ -110,9 +113,11 @@  discard block
 block discarded – undo
110 113
      */
111 114
     final private static function onHyphen(string $nodeString, int $line):Node
112 115
     {
113
-        if (substr($nodeString, 0, 3) === '---')       return new NodeDocStart($nodeString, $line);
114
-        elseif (preg_match(Regex::ITEM, $nodeString))  return new NodeItem($nodeString, $line);
115
-        else {
116
+        if (substr($nodeString, 0, 3) === '---') {
117
+            return new NodeDocStart($nodeString, $line);
118
+        } elseif (preg_match(Regex::ITEM, $nodeString)) {
119
+            return new NodeItem($nodeString, $line);
120
+        } else {
116 121
             return new NodeScalar($nodeString, $line);
117 122
         }
118 123
     }
@@ -126,10 +131,13 @@  discard block
 block discarded – undo
126 131
      */
127 132
     final private static function onNodeAction(string $nodeString, int $line):Node
128 133
     {
129
-        if ($nodeString[0] === '!')     return new NodeTag($nodeString, $line);
130
-        elseif ($nodeString[0] === '&') return new NodeRefDef($nodeString, $line);
131
-        elseif ($nodeString[0] === '*') return new NodeRefCall($nodeString, $line);
132
-        else {
134
+        if ($nodeString[0] === '!') {
135
+            return new NodeTag($nodeString, $line);
136
+        } elseif ($nodeString[0] === '&') {
137
+            return new NodeRefDef($nodeString, $line);
138
+        } elseif ($nodeString[0] === '*') {
139
+            return new NodeRefCall($nodeString, $line);
140
+        } else {
133 141
             throw new \ParseError("Not a action node !! $nodeString[0]");
134 142
         }
135 143
     }
@@ -137,9 +145,11 @@  discard block
 block discarded – undo
137 145
 
138 146
     final private static function onLiteral(string $nodeString, int $line):Node
139 147
     {
140
-        if ($nodeString[0] === '>')      return new NodeLitFolded($nodeString, $line);
141
-        elseif ($nodeString[0] === '|')  return new NodeLit($nodeString, $line);
142
-        else {
148
+        if ($nodeString[0] === '>') {
149
+            return new NodeLitFolded($nodeString, $line);
150
+        } elseif ($nodeString[0] === '|') {
151
+            return new NodeLit($nodeString, $line);
152
+        } else {
143 153
             throw new \ParseError("Not a literal node !! $nodeString[0]");
144 154
         }
145 155
     }
Please login to merge, or discard this patch.
sources/Tag.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
     private const NO_NAME = '%s Error: a tag MUST have a name';
22 22
     private const WRONG_VALUE = "Error : cannot transform tag '%s' for type '%s'";
23 23
     private const LEGACY_TAGS_HANDLERS = ['!str'       => 'strHandler',
24
-                                          '!binary'    => 'binaryHandler',
25
-                                          '!set'       => 'setHandler',
26
-                                          '!omap'      => 'mapHandler',
27
-                                          'php/object' => 'symfonyPHPobjectHandler',
28
-                                          '!inline'    => 'inlineHandler',
29
-                                          '!long'      => 'longHandler'];
24
+                                            '!binary'    => 'binaryHandler',
25
+                                            '!set'       => 'setHandler',
26
+                                            '!omap'      => 'mapHandler',
27
+                                            'php/object' => 'symfonyPHPobjectHandler',
28
+                                            '!inline'    => 'inlineHandler',
29
+                                            '!long'      => 'longHandler'];
30 30
 
31 31
     public static $registeredHandlers = [];
32 32
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $reflectAPI = new \ReflectionClass(self::class);
59 59
         $methodsList = [];
60
-        $list = $reflectAPI->getMethods(RM::IS_FINAL | RM::IS_STATIC & RM::IS_PRIVATE);
60
+        $list = $reflectAPI->getMethods(RM::IS_FINAL|RM::IS_STATIC & RM::IS_PRIVATE);
61 61
         foreach ($list as $method) {
62 62
             $methodsList[$method->name] = $method->getClosure($this);
63 63
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     private function checkHandlerArgument($tagName, $node)
79 79
     {
80
-        if (!($node instanceof Node) && !($node instanceof NodeList) ) {
80
+        if (!($node instanceof Node) && !($node instanceof NodeList)) {
81 81
             throw new \Exception(sprintf(self::WRONG_VALUE, $tagName, gettype($node)));
82 82
         }
83 83
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
         }
46 46
         $this->tagName = $tagName;
47 47
         $this->raw = $raw;
48
-        if (empty(self::$registeredHandlers)) $this->registerLegacyTags();
48
+        if (empty(self::$registeredHandlers)) {
49
+            $this->registerLegacyTags();
50
+        }
49 51
     }
50 52
 
51 53
     /**
@@ -143,7 +145,9 @@  discard block
 block discarded – undo
143 145
     private final static function strHandler(object $node, object &$parent = null)
144 146
     {
145 147
         if ($node instanceof Node) {
146
-            if ($node instanceof NodeKey) $node->build($parent);
148
+            if ($node instanceof NodeKey) {
149
+                $node->build($parent);
150
+            }
147 151
             return ltrim($node->raw);
148 152
         // } elseif ($node instanceof NodeList) {
149 153
         //     return Builder::buildLitteral($node);
Please login to merge, or discard this patch.
sources/Dumper.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         foreach ($array as $key => $item) {
144 144
             $lineStart = current($refKeys) === $key ? "- " : "- $key: ";
145 145
             if (is_scalar($item)) {
146
-                self::add($lineStart.self::dump($item,0), $indent);
146
+                self::add($lineStart.self::dump($item, 0), $indent);
147 147
             } else {
148 148
                 self::add(rtrim($lineStart), $indent);
149 149
                 self::dump($item, $indent + self::INDENT);
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         if (is_array($subject) || $subject instanceof \ArrayIterator) {
214 214
             $max = count($subject);
215 215
             $objectAsArray = is_array($subject) ? $subject : $subject->getArrayCopy();
216
-            if(array_keys($objectAsArray) !== range(0, $max-1)) {
216
+            if (array_keys($objectAsArray) !== range(0, $max - 1)) {
217 217
                 $pairs = $objectAsArray;
218 218
             } else {
219 219
                 $valuesList = [];
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,9 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public static function toString($dataType, int $options = null):string
43 43
     {
44
-        if (is_null($dataType)) throw new \Exception(self::class.": No content to convert to Yaml");
44
+        if (is_null($dataType)) {
45
+            throw new \Exception(self::class.": No content to convert to Yaml");
46
+        }
45 47
         self::$options = is_int($options) ? $options : self::OPTIONS;
46 48
         self::$result = new DLL;
47 49
         if ($dataType instanceof YamlObject) {
@@ -83,8 +85,12 @@  discard block
 block discarded – undo
83 85
     private static function dump($dataType, int $indent)
84 86
     {
85 87
         if (is_scalar($dataType)) {
86
-            if ($dataType === INF) return '.inf';
87
-            if ($dataType === -INF) return '-.inf';
88
+            if ($dataType === INF) {
89
+                return '.inf';
90
+            }
91
+            if ($dataType === -INF) {
92
+                return '-.inf';
93
+            }
88 94
             switch (gettype($dataType)) {
89 95
                 case 'boolean': return $dataType ? 'true' : 'false';
90 96
                 case 'float': //fall through
@@ -106,7 +112,9 @@  discard block
 block discarded – undo
106 112
      */
107 113
     private static function dumpYamlObject(YamlObject $obj)
108 114
     {
109
-        if ($obj->hasDocStart() && self::$result instanceof DLL) self::$result->push("---");
115
+        if ($obj->hasDocStart() && self::$result instanceof DLL) {
116
+            self::$result->push("---");
117
+        }
110 118
         // self::dump($obj, 0);
111 119
         if (count($obj) > 0) {
112 120
             self::dumpArray($obj->getArrayCopy(), 0);
@@ -182,9 +190,13 @@  discard block
 block discarded – undo
182 190
                 self::add(self::dump($obj->value, $indent + self::INDENT), $indent + self::INDENT);
183 191
             }
184 192
         }
185
-        if ($obj instanceof Compact) return self::dumpCompact($obj, $indent);
193
+        if ($obj instanceof Compact) {
194
+            return self::dumpCompact($obj, $indent);
195
+        }
186 196
         //TODO:  consider dumping datetime as date strings according to a format provided by user or default
187
-        if ($obj instanceof \DateTime) return $obj->format(self::DATE_FORMAT);
197
+        if ($obj instanceof \DateTime) {
198
+            return $obj->format(self::DATE_FORMAT);
199
+        }
188 200
         $propList = get_object_vars($obj);
189 201
         foreach ($propList as $property => $value) {
190 202
             if (is_scalar($value) || $value instanceof Compact || $value instanceof \DateTime) {
Please login to merge, or discard this patch.
sources/nodetypes/NodeSetKey.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     public function build(&$parent = null)
30 30
     {
31 31
         $built = is_object($this->value) ? $this->value->build($parent) : null;
32
-        $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" '): $built;
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 34
         if (empty($key)) throw new \Exception("Cant serialize complex key: ".var_export($this->value, true));
35 35
         $parent->{trim($key, '\'" ')} = null;
Please login to merge, or discard this 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_object($this->value) ? $this->value->build($parent) : null;
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/nodetypes/NodeComment.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class NodeComment extends Node
12 12
 {
13
-       /**
14
-     * According to the current Node type and deepest value
15
-     * this indicates if self::parse skips (or not) the parent and previous assignment
16
-     *
17
-     * @param      Node     $target    The parent target Node
18
-     *
19
-     * @return     boolean  True if context, False otherwiser
20
-     * @todo  is this really necessary according ot other checkings out there ?
21
-     */
13
+        /**
14
+         * According to the current Node type and deepest value
15
+         * this indicates if self::parse skips (or not) the parent and previous assignment
16
+         *
17
+         * @param      Node     $target    The parent target Node
18
+         *
19
+         * @return     boolean  True if context, False otherwiser
20
+         * @todo  is this really necessary according ot other checkings out there ?
21
+         */
22 22
     public function skipOnContext(Node &$target):bool
23 23
     {
24 24
         if (!$this->identifier) {
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
         return false;
29 29
     }
30 30
 
31
-   public function needsSpecialProcess(Node &$previous, array &$emptyLines):bool
32
-   {
31
+    public function needsSpecialProcess(Node &$previous, array &$emptyLines):bool
32
+    {
33 33
         $deepest = $previous->getDeepestNode();
34 34
         if (!($previous->getParent() instanceof NodeLiterals)
35 35
             && !($deepest instanceof NodeLiterals)) {
@@ -37,5 +37,5 @@  discard block
 block discarded – undo
37 37
             return true;
38 38
         }
39 39
         return false;
40
-   }
40
+    }
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     public function skipOnContext(Node &$target):bool
23 23
     {
24 24
         if (!$this->identifier) {
25
-            $target = $target->getParent(-1);//if alone-on-line comment --> set parent to root
25
+            $target = $target->getParent(-1); //if alone-on-line comment --> set parent to root
26 26
             return true;
27 27
         }
28 28
         return false;
Please login to merge, or discard this patch.
sources/nodetypes/NodeKey.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function getTargetOnLessIndent(Node $previous):Node
32 32
     {
33 33
         if ($this->indent === 0) {
34
-            return $previous->getParent(-1);//get root
34
+            return $previous->getParent(-1); //get root
35 35
         } else {
36 36
             return parent::getTargetOnLessIndent($previous);
37 37
         }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public function getTargetonEqualIndent(Node &$previous):Node
48 48
     {
49 49
         if ($this->indent === 0) {
50
-            return $previous->getParent(-1);//get root
50
+            return $previous->getParent(-1); //get root
51 51
         } else {
52 52
             return parent::getTargetonEqualIndent($previous);
53 53
         }
Please login to merge, or discard this patch.
sources/nodetypes/NodeCompactSequence.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     {
15 15
         parent::__construct($nodeString, $line);
16 16
         $this->value = new NodeList();
17
-        preg_match_all(Regex::SEQUENCE_VALUES, trim(substr(ltrim($nodeString), 1,-1)), $matches);
17
+        preg_match_all(Regex::SEQUENCE_VALUES, trim(substr(ltrim($nodeString), 1, -1)), $matches);
18 18
         foreach ($matches['item'] as $key => $item) {
19 19
             $this->value->push(new NodeItem('- '.$item, $line));
20 20
         }
Please login to merge, or discard this patch.
sources/nodetypes/NodeLiterals.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,8 +76,8 @@
 block discarded – undo
76 76
         }
77 77
         if ($list->count()) {
78 78
             if ($this->modifier !== '+') {
79
-                 self::litteralStripLeading($list);
80
-                 self::litteralStripTrailing($list);
79
+                    self::litteralStripLeading($list);
80
+                    self::litteralStripTrailing($list);
81 81
             }
82 82
             $first = $list->shift();
83 83
             $refIndent = $first->indent ?? 0;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             $result = substr($first->raw, $first->indent);
87 87
             foreach ($list as $child) {
88 88
                 if ($this instanceof NodeLitFolded) {
89
-                    if($child->indent > $refIndent || ($child instanceof NodeBlank)) {
89
+                    if ($child->indent > $refIndent || ($child instanceof NodeBlank)) {
90 90
                         $separator = "\n";
91 91
                     } else {
92 92
                         $separator = !empty($result) && $result[-1] === "\n" ? '' : $refSeparator;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                         // $val .= $cursor->value;
111 111
                     }*/
112 112
                 }
113
-                $result .= $separator .$val;
113
+                $result .= $separator.$val;
114 114
             }
115 115
         }
116 116
         return $result.($this->modifier === '-' ? "" : "\n");
Please login to merge, or discard this patch.
sources/nodetypes/NodeLit.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@
 block discarded – undo
16 16
         $result = '';
17 17
         if ($list->count()) {
18 18
             if ($modifier !== '+') {
19
-                 self::litteralStripLeading($list);
20
-                 self::litteralStripTrailing($list);
19
+                    self::litteralStripLeading($list);
20
+                    self::litteralStripTrailing($list);
21 21
             }
22 22
             $first = $list->shift();
23 23
             $refIndent = $first->indent ?? 0;
Please login to merge, or discard this patch.