Completed
Push — master ( f50740...419cde )
by stéphane
02:30
created
yaml/Tag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
         if (is_null($tagName)) {
17 17
             throw new \Exception(self::class.": a tag MUST have a name", 1);
18 18
         }
19
-        $this->tagName  = $tagName;
19
+        $this->tagName = $tagName;
20 20
         $this->value = $value;
21 21
     }
22 22
 
Please login to merge, or discard this patch.
yaml/Regex.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@
 block discarded – undo
32 32
     {
33 33
         $d         = "\\d{4}([-\\/])\\d{2}\\1\\d{2}";
34 34
         $h         = "\\d{2}(:)\\d{2}\\2\\d{2}";
35
-        $date      =  "/^$d$/";// 2002-12-14, 2002/12/14
36
-        $canonical =  "/^$d(?:t| )$h\\.\\dz?$/im";// 2001-12-15T02:59:43.1Z
37
-        $spaced    =  "/^$d(?:t| )$h\\.\\d{2} [-+]\\d$/im";// 2001-12-14 21:59:43.10 -5
38
-        $iso8601   =  "/^$d(?:t| )$h\\.\\d{2}[-+]\\d{2}\\2\\d{2}/im";// 2001-12-14t21:59:43.10-05:00
35
+        $date      = "/^$d$/"; // 2002-12-14, 2002/12/14
36
+        $canonical = "/^$d(?:t| )$h\\.\\dz?$/im"; // 2001-12-15T02:59:43.1Z
37
+        $spaced    = "/^$d(?:t| )$h\\.\\d{2} [-+]\\d$/im"; // 2001-12-14 21:59:43.10 -5
38
+        $iso8601   = "/^$d(?:t| )$h\\.\\d{2}[-+]\\d{2}\\2\\d{2}/im"; // 2001-12-14t21:59:43.10-05:00
39 39
         $matchDate      = preg_match($date, $v);
40 40
         $matchCanonical = preg_match($canonical, $v);
41 41
         $matchSpaced    = preg_match($spaced, $v);
Please login to merge, or discard this patch.
yaml/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.
example.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-require_once __DIR__ . '/vendor/autoload.php';
2
+require_once __DIR__.'/vendor/autoload.php';
3 3
 
4 4
 use \Dallgoot\Yaml as Y;
5 5
 
Please login to merge, or discard this patch.
yaml/Node.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
             //modify type according to child
90 90
             switch ($child->type) {
91 91
                 case Y\COMMENT: //fall through
92
-                case Y\KEY:     $this->value->type = Y\MAPPING;break;
93
-                case Y\ITEM:    $this->value->type = Y\SEQUENCE;break;
92
+                case Y\KEY:     $this->value->type = Y\MAPPING; break;
93
+                case Y\ITEM:    $this->value->type = Y\SEQUENCE; break;
94 94
                 // case Y\COMMENT: $this->value->type = Y\RAW;break;
95 95
             }
96 96
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function parse(string $nodeString):Node
117 117
     {
118
-        $nodeValue = preg_replace("/^\t+/m", " ", $nodeString);//permissive to tabs but replacement
118
+        $nodeValue = preg_replace("/^\t+/m", " ", $nodeString); //permissive to tabs but replacement
119 119
         $this->indent = strspn($nodeValue, ' ');
120 120
         $nodeValue = ltrim($nodeValue);
121 121
         if ($nodeValue === '') {
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             case '#': return [Y\COMMENT, ltrim($v)];
153 153
             case "-": return $this->onHyphen($nodeValue);
154 154
             case '%': return [Y\DIRECTIVE, ltrim($v)];
155
-            case '?': return [Y\SET_KEY,   empty($v) ? null : new Node(ltrim($v), $this->line)];
155
+            case '?': return [Y\SET_KEY, empty($v) ? null : new Node(ltrim($v), $this->line)];
156 156
             case ':': return [Y\SET_VALUE, empty($v) ? null : new Node(ltrim($v), $this->line)];
157 157
             case '>': return [Y\LITT_FOLDED, null];
158 158
             case '|': return [Y\LITT, null];
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             if (!is_bool($hasComment)) {
178 178
                 $tmpNode = new Node(trim(substr($keyValue, 0, $hasComment)), $this->line);
179 179
                 if ($tmpNode->type !== Y\PARTIAL) {
180
-                    $comment = new Node(trim(substr($keyValue, $hasComment+1)), $this->line);
180
+                    $comment = new Node(trim(substr($keyValue, $hasComment + 1)), $this->line);
181 181
                     //TODO: modify "identifier" to specify if fullline comment or not
182 182
                     $this->add($comment);
183 183
                     $n = $tmpNode;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         $type = ['!' => Y\TAG, '&' => Y\REF_DEF, '*' => Y\REF_CALL][$nodeValue[0]];
247 247
         $pos = strpos($v, ' ');
248 248
         $this->identifier = is_bool($pos) ? $v : strstr($v, ' ', true);
249
-        $n = is_bool($pos) ? null : (new Node(trim(substr($nodeValue, $pos+1)), $this->line))->setParent($this);
249
+        $n = is_bool($pos) ? null : (new Node(trim(substr($nodeValue, $pos + 1)), $this->line))->setParent($this);
250 250
         return [$type, $n];
251 251
     }
252 252
 
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
     {
261 261
         $v = $this->value;
262 262
         if (is_null($v)) return null;
263
-        if ($this->type & (Y\REF_CALL | Y\SCALAR)) return self::getScalar($v);
264
-        if ($this->type & (Y\COMPACT_MAPPING | Y\COMPACT_SEQUENCE)) return self::getCompact(substr($v, 1, -1), $this->type);
263
+        if ($this->type & (Y\REF_CALL|Y\SCALAR)) return self::getScalar($v);
264
+        if ($this->type & (Y\COMPACT_MAPPING|Y\COMPACT_SEQUENCE)) return self::getCompact(substr($v, 1, -1), $this->type);
265 265
         switch ($this->type) {
266 266
             case Y\JSON:   return json_decode($v, false, 512, JSON_PARTIAL_OUTPUT_ON_ERROR);
267 267
             case Y\QUOTED: return substr($v, 1, -1);
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     {
318 318
         $out = new Compact();
319 319
         if ($type === Y\COMPACT_SEQUENCE) {
320
-            $f = function ($e) { return self::getScalar(trim($e));};
320
+            $f = function($e) { return self::getScalar(trim($e)); };
321 321
             //TODO : that's not robust enough, improve it
322 322
             foreach (array_map($f, explode(",", $mappingOrSeqString)) as $key => $value) {
323 323
                 $out[$key] = $value;
Please login to merge, or discard this patch.
yaml/Yaml.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
     public static function getName($typeInteger)
55 55
     {
56 56
         if (is_null(self::$TYPE_NAMES)) {
57
-            $f = function ($v) { return str_replace('Dallgoot\Yaml\\', '', $v);};
57
+            $f = function($v) { return str_replace('Dallgoot\Yaml\\', '', $v); };
58 58
             self::$TYPE_NAMES = array_map($f, array_flip(get_defined_constants(true)['user']));
59 59
         }
60 60
         return self::$TYPE_NAMES[$typeInteger];
Please login to merge, or discard this patch.
yaml/Builder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
             throw new \ParseError(sprintf(self::INVALID_DOCUMENT, $key));
176 176
         } else {
177 177
             switch (true) {
178
-                case $isSequence: $list->type = Y\SEQUENCE;break;
179
-                case $isSet:      $list->type = Y\SET;break;
178
+                case $isSequence: $list->type = Y\SEQUENCE; break;
179
+                case $isSet:      $list->type = Y\SET; break;
180 180
                 default:          $list->type = Y\MAPPING;
181 181
             }
182 182
         }
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
         $children->rewind();
199 199
         $refIndent = $children->current()->indent;
200 200
         $separator = $type === Y\RAW ? '' : "\n";
201
-        $action = function ($c) { return $c->value; };
202
-        if ($type & Y\LITT_FOLDED) {
201
+        $action = function($c) { return $c->value; };
202
+        if ($type&Y\LITT_FOLDED) {
203 203
             $separator = ' ';
204
-            $action = function ($c) use ($refIndent) {
204
+            $action = function($c) use ($refIndent) {
205 205
                 return $c->indent > $refIndent || ($c->type & Y\BLANK) ? "\n".$c->value : $c->value;
206 206
             };
207 207
         }
Please login to merge, or discard this patch.
yaml/Loader.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
     //public
18 18
     public $errors = [];
19 19
 
20
-    public const EXCLUDE_DIRECTIVES = 1;//DONT include_directive
21
-    public const IGNORE_COMMENTS    = 2;//DONT include_comments
22
-    public const NO_PARSING_EXCEPTIONS = 4;//THROW Exception on parsing Errors
23
-    public const NO_OBJECT_FOR_DATE = 8;//DONT import date strings as dateTime Object
20
+    public const EXCLUDE_DIRECTIVES = 1; //DONT include_directive
21
+    public const IGNORE_COMMENTS    = 2; //DONT include_comments
22
+    public const NO_PARSING_EXCEPTIONS = 4; //THROW Exception on parsing Errors
23
+    public const NO_OBJECT_FOR_DATE = 8; //DONT import date strings as dateTime Object
24 24
     //privates
25 25
     /* @var null|string */
26 26
     private $content;
27 27
     /* @var null|string */
28 28
     private $filePath;
29 29
     /* @var integer */
30
-    private $debug = 0;///TODO: determine levels
30
+    private $debug = 0; ///TODO: determine levels
31 31
     /* @var integer */
32 32
     private $options = 0;
33 33
     //Exceptions messages
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
                     }
113 113
                     $emptyLines = [];
114 114
                     switch ($n->indent <=> $previous->indent) {
115
-                        case -1: $previous->getParent($n->indent)->add($n);break;
116
-                        case 0: $previous->getParent()->add($n);break;
115
+                        case -1: $previous->getParent($n->indent)->add($n); break;
116
+                        case 0: $previous->getParent()->add($n); break;
117 117
                         default:
118 118
                             if ($this->onDeepestType($n, $previous, $lineString)) continue 2;
119 119
                             $previous->add($n);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         // // if ($previous->type & Y\ITEM && $n->type & Y\KEY) {
177 177
         // //     $previous
178 178
         // // }
179
-        if ($deepest->type & (Y\BLANK | Y\SCALAR)) {//|| ($previous->type & (Y\ITEM | Y\SET_KEY))) {
179
+        if ($deepest->type & (Y\BLANK|Y\SCALAR)) {//|| ($previous->type & (Y\ITEM | Y\SET_KEY))) {
180 180
                 $previous = $deepest->getParent();
181 181
         //     // if ($n->type === Y\SCALAR && ($deepest->getParent()->type & Y\LITTERALS)) {
182 182
         //     //     // $deepest->type = Y\SCALAR;
Please login to merge, or discard this patch.