Passed
Push — master ( f0c5ab...d6277d )
by stéphane
01:45
created
sources/Dumper.php 1 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/Loader.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,7 +93,9 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $source = $this->content ?? preg_split("/\n/m", preg_replace('/(\r\n|\r)/', "\n", $strContent), 0, PREG_SPLIT_DELIM_CAPTURE);
95 95
         //TODO : be more permissive on $strContent values
96
-        if (!is_array($source) || !count($source)) throw new \Exception(self::EXCEPTION_LINE_SPLIT);
96
+        if (!is_array($source) || !count($source)) {
97
+            throw new \Exception(self::EXCEPTION_LINE_SPLIT);
98
+        }
97 99
         foreach ($source as $key => $value) {
98 100
             yield ++$key => $value;
99 101
         }
@@ -116,7 +118,9 @@  discard block
 block discarded – undo
116 118
         try {
117 119
             foreach ($generator as $lineNb => $lineString) {
118 120
                 $node = NodeFactory::get($lineString, $lineNb);
119
-                if ($this->needsSpecialProcess($node, $previous)) continue;
121
+                if ($this->needsSpecialProcess($node, $previous)) {
122
+                    continue;
123
+                }
120 124
                 $this->attachBlankLines($previous);
121 125
                 switch ($node->indent <=> $previous->indent) {
122 126
                     case -1: $target = $previous->getTargetOnLessIndent($node);
Please login to merge, or discard this patch.
sources/NodeList.php 2 patches
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 1 patch
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.
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/NodeLitFolded.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@
 block discarded – undo
21 21
         $result = '';
22 22
         if ($list->count()) {
23 23
             if ($this->identifier !== '+') {
24
-                 self::litteralStripLeading($list);
25
-                 self::litteralStripTrailing($list);
24
+                    self::litteralStripLeading($list);
25
+                    self::litteralStripTrailing($list);
26 26
             }
27 27
             $first = $list->shift();
28 28
             $refIndent = $first->indent ?? 0;
Please login to merge, or discard this patch.
sources/nodes/NodeKey.php 1 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/NodeLit.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         $list = $value->filterComment();
24 24
         if (!is_null($list) && $list->count()) {
25 25
             if ($this->identifier !== '+') {
26
-                 self::litteralStripTrailing($list);
26
+                    self::litteralStripTrailing($list);
27 27
             }
28 28
             $list->setIteratorMode(NodeList::IT_MODE_DELETE);
29 29
             $first  = $list->shift();
Please login to merge, or discard this patch.
sources/nodes/NodeSetKey.php 1 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_null($this->value) ? null : $this->value->build();
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.