Passed
Branch master (f496ba)
by stéphane
02:11
created
YamlObject.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function __construct()
22 22
     {
23
-        parent::__construct([], 1);//1 = Array indices can be accessed as properties in read/write.
23
+        parent::__construct([], 1); //1 = Array indices can be accessed as properties in read/write.
24 24
         $this->__yaml__object__api = new API();
25 25
     }
26 26
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public function __call($funcName, $arguments)
29 29
     {
30 30
         $reflectAPI = new \ReflectionClass(get_class($this->__yaml__object__api));
31
-        $getName = function ($o) { return $o->name; };
31
+        $getName = function($o) { return $o->name; };
32 32
         $publicApi  = array_map($getName, $reflectAPI->getMethods(\ReflectionMethod::IS_PUBLIC));
33 33
         $privateApi = array_map($getName, $reflectAPI->getMethods(\ReflectionMethod::IS_PRIVATE));
34 34
         if (!in_array($funcName, $publicApi) && !in_array($funcName, $privateApi)) {
Please login to merge, or discard this patch.
Node.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
         //modify type according to child
64 64
         if ($this->value instanceof DLL && !property_exists($this->value, "type")) {
65 65
             switch ($child->type) {
66
-                case T::KEY:    $this->value->type = T::MAPPING;break;
67
-                case T::ITEM:   $this->value->type = T::SEQUENCE;break;
68
-                case T::SCALAR: $this->value->type = $this->type;break;
66
+                case T::KEY:    $this->value->type = T::MAPPING; break;
67
+                case T::ITEM:   $this->value->type = T::SEQUENCE; break;
68
+                case T::SCALAR: $this->value->type = $this->type; break;
69 69
             }
70 70
         }
71 71
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     */
85 85
     public function parse(String $nodeString):Node
86 86
     {
87
-        $nodeValue = preg_replace("/^\t+/m", " ", $nodeString);//permissive to tabs but replacement
87
+        $nodeValue = preg_replace("/^\t+/m", " ", $nodeString); //permissive to tabs but replacement
88 88
         $this->indent = strspn($nodeValue, ' ');
89 89
         $nodeValue = ltrim($nodeValue);
90 90
         if ($nodeValue === '') {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             case '#': return [T::COMMENT, ltrim($v)];
121 121
             case "-": return $this->onHyphen($nodeValue);
122 122
             case '%': return [T::DIRECTIVE, ltrim($v)];
123
-            case '?': return [T::SET_KEY,   empty($v) ? null : new Node(ltrim($v), $this->line)];
123
+            case '?': return [T::SET_KEY, empty($v) ? null : new Node(ltrim($v), $this->line)];
124 124
             case ':': return [T::SET_VALUE, empty($v) ? null : new Node(ltrim($v), $this->line)];
125 125
             case '>': return [T::LITTERAL_FOLDED, null];
126 126
             case '|': return [T::LITTERAL, null];
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             if (!is_bool($hasComment)) {
141 141
                 $tmpNode = new Node(trim(substr($keyValue, 0, $hasComment)), $this->line);
142 142
                 if ($tmpNode->type !== T::PARTIAL) {
143
-                    $comment = new Node(trim(substr($keyValue, $hasComment+1)), $this->line);
143
+                    $comment = new Node(trim(substr($keyValue, $hasComment + 1)), $this->line);
144 144
                     //TODO: modify "identifier" to specify if fullline comment or not
145 145
                     $this->add($comment);
146 146
                     $n = $tmpNode;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $type = ['!' => T::TAG, '&' => T::REF_DEF, '*' => T::REF_CALL][$nodeValue[0]];
187 187
         $pos = strpos($v, ' ');
188 188
         $this->identifier = is_bool($pos) ? $v : strstr($v, ' ', true);
189
-        $n = is_bool($pos) ? null : (new Node(trim(substr($nodeValue, $pos+1)), $this->line))->setParent($this);
189
+        $n = is_bool($pos) ? null : (new Node(trim(substr($nodeValue, $pos + 1)), $this->line))->setParent($this);
190 190
         return [$type, $n];
191 191
     }
192 192
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             case T::MAPPING_SHORT:  return self::getShortMapping(substr($v, 1, -1));
204 204
             //TODO : that's not robust enough, improve it
205 205
             case T::SEQUENCE_SHORT:
206
-                $f = function ($e) { return self::getScalar(trim($e));};
206
+                $f = function($e) { return self::getScalar(trim($e)); };
207 207
                 return array_map($f, explode(",", substr($v, 1, -1)));
208 208
             default:
209 209
                 trigger_error("Error can not get PHP type for ".T::getName($this->type), E_USER_WARNING);
Please login to merge, or discard this patch.
Loader.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
 {
10 10
     public $errors = [];
11 11
     //options
12
-    public const EXCLUDE_DIRECTIVES = 0001;//DONT include_directive
13
-    public const IGNORE_COMMENTS    = 0010;//DONT include_comments
14
-    public const EXCEPTIONS_PARSING = 0100;//THROW Exception on parsing Errors
15
-    public const NO_OBJECT_FOR_DATE = 1000;//DONT import date strings as dateTime Object
12
+    public const EXCLUDE_DIRECTIVES = 0001; //DONT include_directive
13
+    public const IGNORE_COMMENTS    = 0010; //DONT include_comments
14
+    public const EXCEPTIONS_PARSING = 0100; //THROW Exception on parsing Errors
15
+    public const NO_OBJECT_FOR_DATE = 1000; //DONT import date strings as dateTime Object
16 16
     //
17 17
     private $content;
18 18
     private $filePath;
19
-    private $debug  = 0;//TODO: determine levels
19
+    private $debug = 0; //TODO: determine levels
20 20
     private $options = 0;
21 21
     //Exceptions
22 22
     const INVALID_VALUE        = self::class.": at line %d";
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $specialTypes = [T::LITTERAL, T::LITTERAL_FOLDED, T::EMPTY];
75 75
         try {
76 76
             foreach ($source as $lineNb => $lineString) {
77
-                $n = new Node($lineString, $lineNb + 1);//TODO: useful???-> $this->debug && var_dump($n);
77
+                $n = new Node($lineString, $lineNb + 1); //TODO: useful???-> $this->debug && var_dump($n);
78 78
                 $parent  = $previous;
79 79
                 $deepest = $previous->getDeepestNode();
80 80
                 if ($deepest->type === T::PARTIAL) {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         switch ($deepest->type) {
147 147
             case T::LITTERAL:
148 148
             case T::LITTERAL_FOLDED:
149
-                $n->value = trim($lineString);//fall through
149
+                $n->value = trim($lineString); //fall through
150 150
             case T::REF_DEF://fall through
151 151
             case T::SET_VALUE://fall through
152 152
             case T::TAG:
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             case T::EMPTY:
156 156
             case T::SCALAR:
157 157
                 if ($n->type === T::SCALAR &&
158
-                    !in_array($deepest->getParent()->type, T::$LITTERALS) ) {
158
+                    !in_array($deepest->getParent()->type, T::$LITTERALS)) {
159 159
                     $deepest->type = T::SCALAR;
160 160
                     $deepest->value .= "\n".$n->value;
161 161
                     return true;
Please login to merge, or discard this patch.
Builder.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
         $p = $parent;
33 33
         switch ($type) {
34 34
             case T::MAPPING: //fall through
35
-            case T::SET:      $p = new \StdClass;break;
36
-            case T::SEQUENCE: $p = [];break;
35
+            case T::SET:      $p = new \StdClass; break;
36
+            case T::SEQUENCE: $p = []; break;
37 37
             // case T::KEY: $p = $parent;break;
38 38
         }
39 39
         $out = null;
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
     {
55 55
         list($line, $type, $value, $identifier) = [$node->line, $node->type, $node->value, $node->identifier];
56 56
         switch ($type) {
57
-            case T::COMMENT: self::$root->addComment($line, $value);return;
58
-            case T::DIRECTIVE: return;//TODO
59
-            case T::ITEM: self::buildItem($value, $parent);return;
60
-            case T::KEY:  self::buildKey($node, $parent);return;
57
+            case T::COMMENT: self::$root->addComment($line, $value); return;
58
+            case T::DIRECTIVE: return; //TODO
59
+            case T::ITEM: self::buildItem($value, $parent); return;
60
+            case T::KEY:  self::buildKey($node, $parent); return;
61 61
             case T::REF_DEF: //fall through
62 62
             case T::REF_CALL://TODO: self::build returns what ?
63 63
                 $tmp = is_object($value) ? self::build($value, $parent) : $node->getPhpValue();
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                 $prop = array_keys(get_object_vars($parent));
74 74
                 $key = end($prop);
75 75
                 if (property_exists($value, "type") && in_array($value->type, [T::ITEM, T::MAPPING])) {
76
-                    $p = $value->type === T::ITEM  ? [] : new \StdClass;
76
+                    $p = $value->type === T::ITEM ? [] : new \StdClass;
77 77
                     self::build($value, $p);
78 78
                 } else {
79 79
                     $p = self::build($value, $parent->{$key});
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                 return;
83 83
             case T::TAG:
84 84
                 if ($parent === self::$root) {
85
-                    $parent->addTag($identifier);return;
85
+                    $parent->addTag($identifier); return;
86 86
                 } else {
87 87
                     if (in_array($identifier, ['!binary', '!str'])) {
88 88
                         if ($value->value instanceof DLL) $value->value->type = T::RAW;
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
             throw new \ParseError(sprintf(self::INVALID_DOCUMENT, $key));
171 171
         } else {
172 172
             switch (true) {
173
-                case $isSequence: $list->type = T::SEQUENCE;break;
174
-                case $isSet: $list->type = T::SET;break;
173
+                case $isSequence: $list->type = T::SEQUENCE; break;
174
+                case $isSet: $list->type = T::SET; break;
175 175
                 case $isMapping://fall through
176 176
                 default:$list->type = T::MAPPING;
177 177
             }
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
         $children->rewind();
196 196
         $refIndent = $children->current()->indent;
197 197
         $separator = $type === T::RAW ? '' : "\n";
198
-        $action = function ($c) { return $c->value; };
198
+        $action = function($c) { return $c->value; };
199 199
         if ($type === T::LITTERAL_FOLDED) {
200 200
             $separator = ' ';
201
-            $action = function ($c) use ($refIndent) {
201
+            $action = function($c) use ($refIndent) {
202 202
                 return $c->indent > $refIndent || $c->type === T::EMPTY ? "\n".$c->value : $c->value;
203 203
             };
204 204
         }
Please login to merge, or discard this patch.
Dumper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         if (is_null($dataType)) throw new \Exception(self::class.": No content to convert to Yaml", 1);
30 30
         self::$options = is_int($options) ? $options : self::$options;
31 31
         self::$result = new DLL;
32
-        self::$result->setIteratorMode(DLL::IT_MODE_FIFO | DLL::IT_MODE_DELETE);
32
+        self::$result->setIteratorMode(DLL::IT_MODE_FIFO|DLL::IT_MODE_DELETE);
33 33
         if ($dataType instanceof YamlObject) {
34 34
             self::dumpYamlObject($dataType);
35 35
         } elseif (is_array($dataType) && $dataType[0] instanceof YamlObject) {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         if (is_scalar($dataType)) {
56 56
             switch (gettype($dataType)) {
57
-                case 'boolean': return $dataType ? 'true' : 'false';break;
57
+                case 'boolean': return $dataType ? 'true' : 'false'; break;
58 58
                 case 'float': if (is_infinite($dataType)) return $dataType > 0 ? '.inf' : '-.inf';
59 59
                 case 'double': if (is_nan($dataType)) return '.nan';
60 60
                 default:
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
         foreach ($array as $key => $item) {
90 90
             $lineStart = current($refKeys) === $key ? "- " : "- $key: ";
91 91
             if (is_scalar($item)) {
92
-                self::add($lineStart.$item, $indent );
92
+                self::add($lineStart.$item, $indent);
93 93
             } else {
94
-                self::add($lineStart, $indent );
94
+                self::add($lineStart, $indent);
95 95
                 self::dump($item, $indent + self::indent);
96 96
             }
97 97
             next($refKeys);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         if ($dataType instanceof Tag) {
111 111
             if (is_scalar($dataType->value)) {
112 112
                 return "!".$dataType->tagName.' '.$dataType->value;
113
-            } else{
113
+            } else {
114 114
                 yield "!".$dataType->tagName;
115 115
                 self::dump($dataType->value, $indent + self::indent);
116 116
             }
Please login to merge, or discard this patch.