Passed
Push — master ( 42571c...f8295f )
by stéphane
09:20
created
sources/NodeFactory.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
         elseif ((bool) preg_match(Regex::KEY, $trimmed, $matches)) return new Nodes\Key($nodeString, $line, $matches);
29 29
         else {
30 30
             $first = $trimmed[0];
31
-            $stringGroups = ['-',         '>|' ,   '"\'',    "#%" ,    "{[" ,       ":?" ,       '*&!'];
32
-            $methodGroups = ['Hyphen','Literal','Quoted','Special','Compact','SetElement','NodeAction'];
31
+            $stringGroups = ['-', '>|', '"\'', "#%", "{[", ":?", '*&!'];
32
+            $methodGroups = ['Hyphen', 'Literal', 'Quoted', 'Special', 'Compact', 'SetElement', 'NodeAction'];
33 33
             foreach ($stringGroups as $groupIndex => $stringRef) {
34 34
                 if (is_int(strpos($stringRef, $first))) {
35 35
                     $methodName = 'on'.$methodGroups[$groupIndex];
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             ini_restore($backtrack_setting);
116 116
 
117 117
             if (is_bool($isMapping) || is_bool($isSequence)) {
118
-                throw new \Exception("Regex Error for ".(is_bool($isMapping) ? 'mapping:' :'sequence:').preg_last_error());
118
+                throw new \Exception("Regex Error for ".(is_bool($isMapping) ? 'mapping:' : 'sequence:').preg_last_error());
119 119
             }
120 120
             if ($isMapping) {
121 121
                 // var_dump(Regex::MAPPING, trim($nodeString));
Please login to merge, or discard this patch.
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,10 +23,13 @@  discard block
 block discarded – undo
23 23
     final public static function get($nodeString = null, $line = 0):NodeGeneric
24 24
     {
25 25
         $trimmed = ltrim($nodeString);
26
-        if ($trimmed === '')                                return new Nodes\Blank($nodeString, $line);
27
-        elseif (substr($trimmed, 0, 3) === '...')           return new Nodes\DocEnd($nodeString, $line);
28
-        elseif ((bool) preg_match(Regex::KEY, $trimmed, $matches)) return new Nodes\Key($nodeString, $line, $matches);
29
-        else {
26
+        if ($trimmed === '') {
27
+            return new Nodes\Blank($nodeString, $line);
28
+        } elseif (substr($trimmed, 0, 3) === '...') {
29
+            return new Nodes\DocEnd($nodeString, $line);
30
+        } elseif ((bool) preg_match(Regex::KEY, $trimmed, $matches)) {
31
+            return new Nodes\Key($nodeString, $line, $matches);
32
+        } else {
30 33
             $first = $trimmed[0];
31 34
             $stringGroups = ['-',         '>|' ,   '"\'',    "#%" ,    "{[" ,       ":?" ,       '*&!'];
32 35
             $methodGroups = ['Hyphen','Literal','Quoted','Special','Compact','SetElement','NodeAction'];
@@ -137,9 +140,11 @@  discard block
 block discarded – undo
137 140
      */
138 141
     final private static function onHyphen(string $first, string $nodeString, int $line):NodeGeneric
139 142
     {
140
-        if (substr($nodeString, 0, 3) === '---')              return new Nodes\DocStart($nodeString, $line);
141
-        elseif ((bool) preg_match(Regex::ITEM, ltrim($nodeString)))  return new Nodes\Item($nodeString, $line);
142
-        else {
143
+        if (substr($nodeString, 0, 3) === '---') {
144
+            return new Nodes\DocStart($nodeString, $line);
145
+        } elseif ((bool) preg_match(Regex::ITEM, ltrim($nodeString))) {
146
+            return new Nodes\Item($nodeString, $line);
147
+        } else {
143 148
             return new Nodes\Scalar($nodeString, $line);
144 149
         }
145 150
     }
Please login to merge, or discard this patch.
sources/Builder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
                     $buffer->push($child);
57 57
                 }
58 58
             }
59
-            $documents[] = $this->buildDocument($buffer, count($documents) +1);
59
+            $documents[] = $this->buildDocument($buffer, count($documents) + 1);
60 60
         } catch (\Throwable $e) {
61 61
             throw new \Exception($e->getMessage(), 1, $e);
62 62
         }
Please login to merge, or discard this patch.
sources/Loader.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
     //public
21 21
     /* @var null|string */
22 22
     public static $error;
23
-    public const IGNORE_DIRECTIVES     = 0b0001;//DONT include_directive
24
-    public const IGNORE_COMMENTS       = 0b0010;//DONT include_comments
25
-    public const NO_PARSING_EXCEPTIONS = 0b0100;//DONT throw Exception on parsing errors
26
-    public const NO_OBJECT_FOR_DATE    = 0b1000;//DONT import date strings as dateTime Object
23
+    public const IGNORE_DIRECTIVES     = 0b0001; //DONT include_directive
24
+    public const IGNORE_COMMENTS       = 0b0010; //DONT include_comments
25
+    public const NO_PARSING_EXCEPTIONS = 0b0100; //DONT throw Exception on parsing errors
26
+    public const NO_OBJECT_FOR_DATE    = 0b1000; //DONT import date strings as dateTime Object
27 27
 
28 28
     //private
29 29
     /* @var null|array */
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
     {
179 179
         $deepest = $previous->getDeepestNode();
180 180
         if ($deepest instanceof Nodes\Partial) {
181
-            return $deepest->specialProcess($current,  $this->_blankBuffer);
182
-        } elseif(!($current instanceof Nodes\Partial)) {
181
+            return $deepest->specialProcess($current, $this->_blankBuffer);
182
+        } elseif (!($current instanceof Nodes\Partial)) {
183 183
             return $current->specialProcess($previous, $this->_blankBuffer);
184 184
         }
185 185
         return false;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,8 +129,12 @@
 block discarded – undo
129 129
         try {
130 130
             foreach ($generator as $lineNB => $lineString) {
131 131
                 $node = NodeFactory::get($lineString, $lineNB);
132
-                if ($this->_debug === 1) echo $lineNB.":".get_class($node)."\n";
133
-                if ($this->needsSpecialProcess($node, $previous)) continue;
132
+                if ($this->_debug === 1) {
133
+                    echo $lineNB.":".get_class($node)."\n";
134
+                }
135
+                if ($this->needsSpecialProcess($node, $previous)) {
136
+                    continue;
137
+                }
134 138
                 $this->_attachBlankLines($previous);
135 139
                 switch ($node->indent <=> $previous->indent) {
136 140
                     case -1: $target = $previous->getTargetOnLessIndent($node);
Please login to merge, or discard this patch.
sources/tag/CoreSchema.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function str($node, &$parent = null)
59 59
     {
60
-        if($node instanceof Nodes\Literals){
60
+        if ($node instanceof Nodes\Literals) {
61 61
             $node = $node->value;
62 62
         }
63 63
         if ($node instanceof Nodes\NodeGeneric) {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 $list[] = $this->str($child);
73 73
             }
74 74
             // return new Nodes\Scalar(implode('',$list), 0);
75
-            return implode('',$list);
75
+            return implode('', $list);
76 76
         }
77 77
     }
78 78
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                 $keyValue = $key->value->build();
134 134
                 if (is_null($parent)) {
135 135
                     return [$keyName => $keyValue];
136
-                } else{
136
+                } else {
137 137
                     $parent[$keyName] = $keyValue;
138 138
                 }
139 139
             } else {
Please login to merge, or discard this patch.
examples/testing.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@
 block discarded – undo
6 6
 /**
7 7
  * Testing/Debugging Loader
8 8
  */
9
-const JSON_OPTIONS = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_PARTIAL_OUTPUT_ON_ERROR;
9
+const JSON_OPTIONS = JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_LINE_TERMINATORS|JSON_UNESCAPED_UNICODE|JSON_PRESERVE_ZERO_FRACTION|JSON_PARTIAL_OUTPUT_ON_ERROR;
10 10
 
11 11
 $debug = (int) (isset($argv[1]) ? $argv[1] : null);
12 12
 $file = (string) (isset($argv[2]) ? $argv[2] : null);
13
-echo memory_get_usage() . "\n";
13
+echo memory_get_usage()."\n";
14 14
 /* USE CASE 1
15 15
 * load and parse if file exists
16 16
 */
17
-$content = file_get_contents($file);//var_dump($content);
17
+$content = file_get_contents($file); //var_dump($content);
18 18
 $yaml = Yaml::parse($content, 0, $debug);
19 19
 
20
-echo memory_get_usage() . "\n";
20
+echo memory_get_usage()."\n";
21 21
 // var_dump($yaml);
22 22
 var_dump(json_encode($yaml, JSON_OPTIONS));
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
sources/nodes/Quoted.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,6 +13,6 @@
 block discarded – undo
13 13
     public function build(&$parent = null)
14 14
     {
15 15
         // return substr(Scalar::replaceSequences(trim($this->raw)), 1,-1);
16
-        return (new Scalar('', 0))->replaceSequences(substr(trim($this->raw), 1,-1));
16
+        return (new Scalar('', 0))->replaceSequences(substr(trim($this->raw), 1, -1));
17 17
     }
18 18
 }
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
examples/write.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php
2 2
 define('PROJECT_ROOT', __DIR__."/../");
3 3
 
4
-require_once PROJECT_ROOT . 'vendor/autoload.php';
4
+require_once PROJECT_ROOT.'vendor/autoload.php';
5 5
 
6 6
 use Dallgoot\Yaml;
7 7
 
8 8
 
9 9
 $testName = 'yamlObject_properties';
10
-$yamlObject = (include PROJECT_ROOT . "tests/cases/dumping/$testName.php");
10
+$yamlObject = (include PROJECT_ROOT."tests/cases/dumping/$testName.php");
11 11
 
12 12
 
13 13
 $text = Yaml::dump($yamlObject, 0);
14 14
 
15 15
 
16
-$nameResultPair = get_object_vars(/** @scrutinizer ignore-type */ Yaml::parseFile(PROJECT_ROOT . 'tests/definitions/dumping_tests.yml'));
16
+$nameResultPair = get_object_vars(/** @scrutinizer ignore-type */ Yaml::parseFile(PROJECT_ROOT.'tests/definitions/dumping_tests.yml'));
17 17
 
18 18
 
19 19
 if ($nameResultPair[$testName] === $text) {
Please login to merge, or discard this patch.
examples/batch_read.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@
 block discarded – undo
7 7
 // USE CASE 3
8 8
 $yamlObjList = [];
9 9
 $yloader = new Loader(null, 0, $debug);
10
-foreach(['examples/dummy.yml', 'examples/config.yml'] as $key => $fileName)
10
+foreach (['examples/dummy.yml', 'examples/config.yml'] as $key => $fileName)
11 11
 {
12
-    $yamlObjList[] =  $yloader->load($fileName)->parse();
12
+    $yamlObjList[] = $yloader->load($fileName)->parse();
13 13
 }
14 14
 
15 15
 var_dump($yamlObjList);
Please login to merge, or discard this patch.
sources/nodes/Anchor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
             try {
19 19
                 return $yamlObject->getReference($name);
20 20
             } catch (\Throwable $e) {
21
-                throw new \ParseError("Unknown anchor : '$name' this:".$this->anchor,1,$e);
21
+                throw new \ParseError("Unknown anchor : '$name' this:".$this->anchor, 1, $e);
22 22
             }
23 23
         } else {
24 24
             $built = is_null($this->value) ? null : $this->value->build($parent);
Please login to merge, or discard this patch.