Passed
Push — master ( 9bf5f8...0872bb )
by stéphane
02:09
created
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);
@@ -181,9 +189,13 @@  discard block
 block discarded – undo
181 189
                 self::add(self::dump($obj->value, $indent + self::INDENT), $indent + self::INDENT);
182 190
             }
183 191
         }
184
-        if ($obj instanceof Compact) return self::dumpCompact($obj, $indent);
192
+        if ($obj instanceof Compact) {
193
+            return self::dumpCompact($obj, $indent);
194
+        }
185 195
         //TODO:  consider dumping datetime as date strings according to a format provided by user or default
186
-        if ($obj instanceof \DateTime) return $obj->format(self::DATE_FORMAT);
196
+        if ($obj instanceof \DateTime) {
197
+            return $obj->format(self::DATE_FORMAT);
198
+        }
187 199
         $propList = get_object_vars($obj);
188 200
         foreach ($propList as $property => $value) {
189 201
             if (is_scalar($value) || $value instanceof Compact || $value instanceof \DateTime) {
Please login to merge, or discard this patch.
examples/load_modify_save.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Dallgoot\Yaml;
3 3
 
4
-require_once __DIR__ . '/../../dependencies/autoload.php';
4
+require_once __DIR__.'/../../dependencies/autoload.php';
5 5
 
6 6
 use Dallgoot;
7 7
 
8
-$fileName = __DIR__ . '/../dummy.yml';
8
+$fileName = __DIR__.'/../dummy.yml';
9 9
 
10 10
 $yamlObject = Yaml::parseFile($fileName, $options = null, $debug = null);
11 11
 
Please login to merge, or discard this patch.
sources/NodeList.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         foreach ($tmp as $child) {
48 48
             if (!($child instanceof NodeComment)
49 49
                 && !($child instanceof NodeDirective)
50
-                && !($child instanceof NodeDocstart && is_null($child->value)) ) return true;
50
+                && !($child instanceof NodeDocstart && is_null($child->value))) return true;
51 51
         }
52 52
         return false;
53 53
     }
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
     public function push($node)
56 56
     {
57 57
         $type = null;
58
-        if     ($node instanceof NodeItem )    $type = self::SEQUENCE;
58
+        if ($node instanceof NodeItem)    $type = self::SEQUENCE;
59 59
         elseif ($node instanceof NodeKey)      $type = self::MAPPING;
60 60
         elseif ($node instanceof NodeSetKey
61 61
              || $node instanceof NodeSetValue) {
62 62
             $type = self::SET;
63
-        } elseif ($node instanceof NodeScalar ){
63
+        } elseif ($node instanceof NodeScalar) {
64 64
             $type = self::MULTILINE;
65 65
         }
66 66
         if (!is_null($type) && $this->checkTypeCoherence($type)) {
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
             if ($child instanceof NodeComment) {
144 144
                 $child->build();
145 145
             } else {
146
-                if($child->value instanceof NodeComment) {
146
+                if ($child->value instanceof NodeComment) {
147 147
                     $child->value->build();
148 148
                     $child->value = null;
149
-                } elseif($child->value instanceof NodeList) {
149
+                } elseif ($child->value instanceof NodeList) {
150 150
                     $child->value = $child->value->filterComment();
151 151
                 }
152 152
                 $out->push($child);
Please login to merge, or discard this 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.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -79,12 +79,12 @@
 block discarded – undo
79 79
      */
80 80
     public function checkTypeCoherence($estimatedType):bool
81 81
     {
82
-       // if ($this->type === self::MAPPING) {
83
-       //     if ($estimatedType === self::SEQUENCE) {
84
-       //         throw new \ParseError("Error : no coherence in types", 1);
85
-       //     }
86
-       // }
87
-       return (bool) $estimatedType;
82
+        // if ($this->type === self::MAPPING) {
83
+        //     if ($estimatedType === self::SEQUENCE) {
84
+        //         throw new \ParseError("Error : no coherence in types", 1);
85
+        //     }
86
+        // }
87
+        return (bool) $estimatedType;
88 88
     }
89 89
 
90 90
     public function build(&$parent = null)
Please login to merge, or discard this patch.
sources/TagFactory.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@
 block discarded – undo
15 15
     private const NO_NAME = '%s Error: a tag MUST have a name';
16 16
     private const WRONG_VALUE = "Error : cannot transform tag '%s' for type '%s'";
17 17
     private const LEGACY_TAGS_HANDLERS = ['!!str'       => 'strHandler',
18
-                                          '!!binary'    => 'binaryHandler',
19
-                                          '!set'        => 'setHandler',
20
-                                          '!!omap'       => 'omapHandler',
21
-                                          '!php/object' => 'symfonyPHPobjectHandler',
22
-                                          '!inline'     => 'inlineHandler',
23
-                                      ];
18
+                                            '!!binary'    => 'binaryHandler',
19
+                                            '!set'        => 'setHandler',
20
+                                            '!!omap'       => 'omapHandler',
21
+                                            '!php/object' => 'symfonyPHPobjectHandler',
22
+                                            '!inline'     => 'inlineHandler',
23
+                                        ];
24 24
 
25 25
     public static $registeredHandlers = [];
26 26
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $reflectAPI = new \ReflectionClass(self::class);
35 35
         $methodsList = [];
36
-        $list = $reflectAPI->getMethods(RM::IS_FINAL | RM::IS_STATIC & RM::IS_PRIVATE);
36
+        $list = $reflectAPI->getMethods(RM::IS_FINAL|RM::IS_STATIC & RM::IS_PRIVATE);
37 37
         foreach ($list as $method) {
38 38
             $methodsList[$method->name] = $method->getClosure();
39 39
         }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             foreach ($node as $key => $child) {
104 104
                 $list[] = self::strHandler($child)->raw;
105 105
             }
106
-            return new NodeScalar(implode('',$list), 0);
106
+            return new NodeScalar(implode('', $list), 0);
107 107
         }
108 108
     }
109 109
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     public static function transform(string $identifier, $value)
171 171
     {
172 172
         if (self::isKnown($identifier)) {
173
-            if (!($value instanceof Node) && !($value instanceof NodeList) ) {
173
+            if (!($value instanceof Node) && !($value instanceof NodeList)) {
174 174
                 throw new \Exception(sprintf(self::WRONG_VALUE, $identifier, gettype($value)));
175 175
             }
176 176
             return self::$registeredHandlers[$identifier]($value);
Please login to merge, or discard this patch.
sources/nodes/NodeComment.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@
 block discarded – undo
10 10
  */
11 11
 class NodeComment extends Node
12 12
 {
13
-   public function specialProcess(Node &$previous, array &$emptyLines):bool
14
-   {
13
+    public function specialProcess(Node &$previous, array &$emptyLines):bool
14
+    {
15 15
         $previous->getRoot()->add($this);
16 16
         return true;
17
-   }
17
+    }
18 18
 
19
-   public function build(&$parent = null)
20
-   {
19
+    public function build(&$parent = null)
20
+    {
21 21
         $root = $this->getRoot();
22 22
         $yamlObject = $root->getYamlObject();
23 23
         $yamlObject->addComment($this->line, $this->raw);
24
-   }
24
+    }
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
sources/nodes/NodeCompactSequence.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     public function __construct(string $nodeString, int $line)
14 14
     {
15 15
         parent::__construct($nodeString, $line);
16
-        preg_match_all(Regex::SEQUENCE_VALUES, trim(substr(trim($nodeString), 1,-1)), $matches);
16
+        preg_match_all(Regex::SEQUENCE_VALUES, trim(substr(trim($nodeString), 1, -1)), $matches);
17 17
         foreach ($matches['item'] as $key => $item) {
18 18
             $i = new NodeItem('', $line);
19 19
             $i->indent = null;
Please login to merge, or discard this patch.
sources/nodes/NodeCompactMapping.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     public function __construct(string $nodeString, int $line)
14 14
     {
15 15
         parent::__construct($nodeString, $line);
16
-        preg_match_all(Regex::MAPPING_VALUES, trim(substr(ltrim($nodeString), 1,-1)), $matches);
16
+        preg_match_all(Regex::MAPPING_VALUES, trim(substr(ltrim($nodeString), 1, -1)), $matches);
17 17
         foreach ($matches['k'] as $index => $property) {
18 18
             $pair = $property.': '.trim($matches['v'][$index]);
19 19
             $child = NodeFactory::get($pair, $line);
Please login to merge, or discard this patch.
sources/nodes/NodeKey.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function add(Node $child):Node
46 46
     {
47
-        if ($this->value instanceof Node && isOneOf($this->value, ['NodeLit','NodeLitFolded', 'NodeAnchor'])) {
47
+        if ($this->value instanceof Node && isOneOf($this->value, ['NodeLit', 'NodeLitFolded', 'NodeAnchor'])) {
48 48
             return $this->value->add($child);
49 49
         } else {
50 50
             return parent::add($child);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         if ($current instanceof NodeComment) {
80 80
             return true;
81 81
         }
82
-        if($current instanceof NodeScalar) {
82
+        if ($current instanceof NodeScalar) {
83 83
             return isOneOf($node, ['NodeScalar', 'NodeBlank']);
84 84
         }
85 85
         if ($current instanceof NodeItem) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
     public function setIdentifier(string $keyString)
28 28
     {
29 29
         if ($keyString === '') {
30
-           throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line));
30
+            throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line));
31 31
         } else {
32 32
             $keyNode = NodeFactory::get($keyString);
33 33
             if (!is_null($keyNode->anchor)) {
Please login to merge, or discard this patch.
sources/nodes/NodeQuoted.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
 {
13 13
     public function build(&$parent = null)
14 14
     {
15
-        return substr(trim($this->raw), 1,-1);
15
+        return substr(trim($this->raw), 1, -1);
16 16
     }
17 17
 }
18 18
\ No newline at end of file
Please login to merge, or discard this patch.