Test Failed
Push — master ( dcbcc7...505ce0 )
by stéphane
02:34
created
sources/nodes/LiteralFolded.php 2 patches
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
         $list = $value->filterComment();
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
         if ($list->count()) {
28 28
             $refSeparator = ' ';
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@
 block discarded – undo
31 31
             $result = $this->getChildValue($first, $indent);
32 32
             foreach ($list as $child) {
33 33
                 $separator = ($result && $result[-1] === "\n") ? '' : $refSeparator;
34
-                if($child->indent > $indent || $child instanceof Blank) {
34
+                if ($child->indent > $indent || $child instanceof Blank) {
35 35
                     $separator = "\n";
36 36
                 }
37
-                $result .= $separator .$this->getChildValue($child, $indent);
37
+                $result .= $separator.$this->getChildValue($child, $indent);
38 38
             }
39 39
         }
40 40
         return $result;
Please login to merge, or discard this patch.
sources/nodes/abstract/Literals.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,9 @@
 block discarded – undo
32 32
 
33 33
     public function add(NodeGeneric $child):NodeGeneric
34 34
     {
35
-        if (is_null($this->value)) $this->value = new NodeList();
35
+        if (is_null($this->value)) {
36
+            $this->value = new NodeList();
37
+        }
36 38
         $candidate = $child;
37 39
         if (!$child->isOneOf('Scalar', 'Blank', 'Comment', 'Quoted')) {
38 40
             $candidate = new Scalar((string) $child->raw, $child->line);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
      * @return     string  The child value.
97 97
      * @todo       double check behaviour for KEY and ITEM
98 98
      */
99
-    protected function getChildValue($child, $refIndent=0):string
99
+    protected function getChildValue($child, $refIndent = 0):string
100 100
     {
101 101
         $value = $child->value;
102 102
         $start = '';
Please login to merge, or discard this patch.
sources/nodes/Key.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     public function setIdentifier(string $keyString)
36 36
     {
37 37
         if ($keyString === '') {
38
-           throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line));
38
+            throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line));
39 39
         } else {
40 40
             $node = NodeFactory::get($keyString);
41 41
             if ($node->isOneOf('Tag', 'Quoted')) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
     public function add(NodeGeneric $child):NodeGeneric
56 56
     {
57
-        if ($this->value instanceof NodeGeneric && $this->value->isOneOf('Literal','LiteralFolded', 'Anchor')) {
57
+        if ($this->value instanceof NodeGeneric && $this->value->isOneOf('Literal', 'LiteralFolded', 'Anchor')) {
58 58
             return $this->value->add($child);
59 59
         } else {
60 60
             return parent::add($child);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         if (is_null($this->value) || $node instanceof Comment) {
86 86
             return true;
87
-        } elseif($this->value instanceof NodeGeneric) {
87
+        } elseif ($this->value instanceof NodeGeneric) {
88 88
             $current = $this->value;
89 89
         } else {
90 90
             $current = $this->value->current();
Please login to merge, or discard this patch.
sources/tag/TagFactory.php 2 patches
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,7 +62,6 @@  discard block
 block discarded – undo
62 62
 %TAG !! tag:example.com,2000:app/
63 63
 %TAG !e! tag:example.com,2000:app/
64 64
 !<tag:yaml.org,2002:str> foo :
65
-
66 65
      */
67 66
     /**
68 67
      * Add Handlers for legacy Yaml tags
@@ -107,16 +106,16 @@  discard block
 block discarded – undo
107 106
             self::createCoreSchema();
108 107
         }
109 108
         if (!($value instanceof NodeGeneric) && !($value instanceof NodeList) ) {
110
-              throw new \Exception(sprintf(self::WRONG_VALUE, $identifier, gettype($value)));
109
+                throw new \Exception(sprintf(self::WRONG_VALUE, $identifier, gettype($value)));
111 110
         } else {
112 111
             // try {
113 112
                 if (!preg_match(Regex::TAG_PARTS, $identifier, $matches)) {
114 113
                     throw new \UnexpectedValueException("Tag '$identifier' is invalid", 1);
115 114
                 }
116 115
                 return self::runHandler($matches['handle'],
117
-                                          $matches['tagname'],
118
-                                          $value,
119
-                                          $parent);
116
+                                            $matches['tagname'],
117
+                                            $value,
118
+                                            $parent);
120 119
             // } catch (\UnexpectedValueException $e) {
121 120
             //     return new Tagged($identifier, is_null($value) ? null : $value->build($parent));
122 121
             // } catch (\Throwable $e) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@
 block discarded – undo
106 106
         if (count(self::$schemas) === 0) {
107 107
             self::createCoreSchema();
108 108
         }
109
-        if (!($value instanceof NodeGeneric) && !($value instanceof NodeList) ) {
109
+        if (!($value instanceof NodeGeneric) && !($value instanceof NodeList)) {
110 110
               throw new \Exception(sprintf(self::WRONG_VALUE, $identifier, gettype($value)));
111 111
         } else {
112 112
             // try {
Please login to merge, or discard this patch.
sources/nodes/DocStart.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
             throw new \Exception(__METHOD__." expects a YamlObject as parent", 1);
40 40
         }
41 41
         if (!is_null($this->value)) {
42
-            if ($this->value instanceof Tag){
42
+            if ($this->value instanceof Tag) {
43 43
                 preg_match(Regex::TAG_PARTS, $this->value->raw, $tagparts);
44 44
                 if (preg_match("/(?(DEFINE)".Regex::TAG_URI.')(?&url)/', $tagparts['tagname'], $matches)) {
45 45
                     // throw new \UnexpectedValueException("Tag '".$this->value->raw."' is invalid", 1);
Please login to merge, or discard this patch.
sources/nodes/Tag.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
         } catch (\UnexpectedValueException $e) {
60 60
             return new Tagged($this->tag, is_null($value) ? null : $this->value->build($parent));
61 61
         } catch (\Throwable $e) {
62
-            throw new \Exception("Tagged value could not be transformed for tag '$this->tag'", 1, $e);;
62
+            throw new \Exception("Tagged value could not be transformed for tag '$this->tag'", 1, $e); ;
63 63
         }
64 64
     }
65 65
 }
66 66
\ No newline at end of file
Please login to merge, or discard this patch.
sources/DumperHandlers.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             }
102 102
         }
103 103
         $previousCompactMode = $this->dumper->_compactMode;
104
-        $this->dumper->_compactMode =  true;
104
+        $this->dumper->_compactMode = true;
105 105
         $result = $this->dumper->iteratorToString(new \ArrayIterator($source), $keyMask, ', ', $indent);
106 106
         $this->dumper->_compactMode = $previousCompactMode;
107 107
         return sprintf($structureFormat, $result);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         // Example 5.13. Escaped Characters
124 124
 
125 125
         $str = json_encode(ltrim($str));
126
-        return strspn(substr($str,1,-1), "-:?{}[]#,&*!>|'\"%") > 0 ? $str : trim($str, '"');
126
+        return strspn(substr($str, 1, -1), "-:?{}[]#,&*!>|'\"%") > 0 ? $str : trim($str, '"');
127 127
     }
128 128
 
129 129
     public function dumpTagged(Tagged $obj, int $indent):string
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,12 @@
 block discarded – undo
22 22
 
23 23
     public function dumpScalar($dataType):string
24 24
     {
25
-        if ($dataType === \INF) return '.inf';
26
-        if ($dataType === -\INF) return '-.inf';
25
+        if ($dataType === \INF) {
26
+            return '.inf';
27
+        }
28
+        if ($dataType === -\INF) {
29
+            return '-.inf';
30
+        }
27 31
         $precision = "%.".$this->dumper->floatPrecision."F";
28 32
         switch (gettype($dataType)) {
29 33
             case 'boolean': return $dataType ? 'true' : 'false';
Please login to merge, or discard this patch.
sources/Dumper.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
     public function dumpYamlObject(YamlObject $obj):string
106 106
     {
107 107
         if ($this->multipleDocs || $obj->hasDocStart() || $obj->isTagged()) {
108
-           $this->multipleDocs = true;
109
-          // && $this->$result instanceof DLL) $this->$result->push("---");
108
+            $this->multipleDocs = true;
109
+            // && $this->$result instanceof DLL) $this->$result->push("---");
110 110
         }
111 111
         // $this->insertComments($obj->getComment());
112 112
         if (count($obj) > 0) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 
120 120
     public function iteratorToString(\Iterator $iterable,
121
-                                      string $keyMask, string $itemSeparator, int $indent):string
121
+                                        string $keyMask, string $itemSeparator, int $indent):string
122 122
     {
123 123
         $pairs = [];
124 124
         $valueIndent = $indent + self::INDENT;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     private $handler;
32 32
 
33 33
 
34
-    public function __construct($options=null)
34
+    public function __construct($options = null)
35 35
     {
36 36
         $this->options = is_int($options) ? $options : self::OPTIONS;
37 37
         $this->handler = new DumperHandlers($this);
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     {
51 51
         if (empty($dataType)) throw new \Exception(self::class.": No content to convert to Yaml");
52 52
         if (is_scalar($dataType)) {
53
-            return "--- ".$this->handler->dumpScalar($dataType). self::LINEFEED ;
53
+            return "--- ".$this->handler->dumpScalar($dataType).self::LINEFEED;
54 54
         }
55 55
         return $this->dump($dataType, 0);
56 56
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,9 @@
 block discarded – undo
48 48
      */
49 49
     public function toString($dataType, int $options = null):string
50 50
     {
51
-        if (empty($dataType)) throw new \Exception(self::class.": No content to convert to Yaml");
51
+        if (empty($dataType)) {
52
+            throw new \Exception(self::class.": No content to convert to Yaml");
53
+        }
52 54
         if (is_scalar($dataType)) {
53 55
             return "--- ".$this->handler->dumpScalar($dataType). self::LINEFEED ;
54 56
         }
Please login to merge, or discard this patch.
sources/nodes/Scalar.php 3 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -100,35 +100,35 @@
 block discarded – undo
100 100
         if (Regex::isDate($v))   return ($this->getRoot()->getYamlObject()->getOptions() & Loader::NO_OBJECT_FOR_DATE) && !$onlyScalar ? date_create($v) : $v;
101 101
         if (Regex::isNumber($v)) return $this->getNumber($v);
102 102
         $types = ['yes'   => true,
103
-                  'no'    => false,
104
-                  'true'  => true,
105
-                  'false' => false,
106
-                  'null'  => null,
107
-                  '.inf'  => \INF,
108
-                  '-.inf' => -\INF,
109
-                  '.nan'  => \NAN
103
+                    'no'    => false,
104
+                    'true'  => true,
105
+                    'false' => false,
106
+                    'null'  => null,
107
+                    '.inf'  => \INF,
108
+                    '-.inf' => -\INF,
109
+                    '.nan'  => \NAN
110 110
         ];
111 111
         return array_key_exists(strtolower($v), $types) ? $types[strtolower($v)] : $this->replaceSequences($v);
112 112
     }
113 113
 
114 114
     public function replaceSequences($value='')
115 115
     {
116
-      $replaceUnicodeSeq = function ($matches) {
116
+        $replaceUnicodeSeq = function ($matches) {
117 117
             return json_decode('"'.$matches[1].'"');
118
-      };
119
-      $replaceNonPrintable = function ($matches) {
118
+        };
119
+        $replaceNonPrintable = function ($matches) {
120 120
             // var_dump($matches[1]);
121 121
         return $matches[1]."";
122
-      };
122
+        };
123 123
 // preg_match( "/[^\x{06F0}-\x{06F9}\x]+/u" , '۱۲۳۴۵۶۷۸۹۰' );
124
-      return preg_replace_callback_array(
125
-          [
126
-              '/((?<![\\\\])\\\\x[0-9a-f]{2})/i' => $replaceUnicodeSeq,
127
-              '/((?<![\\\\])\\\\u[0-9a-f]{4,})/i' => $replaceUnicodeSeq,
128
-              '/(\\\\b|\\\\n|\\\\t|\\\\r)/' => $replaceNonPrintable
129
-          ],
130
-          $value
131
-      );
124
+        return preg_replace_callback_array(
125
+            [
126
+                '/((?<![\\\\])\\\\x[0-9a-f]{2})/i' => $replaceUnicodeSeq,
127
+                '/((?<![\\\\])\\\\u[0-9a-f]{4,})/i' => $replaceUnicodeSeq,
128
+                '/(\\\\b|\\\\n|\\\\t|\\\\r)/' => $replaceNonPrintable
129
+            ],
130
+            $value
131
+        );
132 132
     }
133 133
 
134 134
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     public function getTargetOnLessIndent(NodeGeneric &$node):NodeGeneric
52 52
     {
53
-        if ($node instanceof Scalar || $node instanceof Blank ) {
53
+        if ($node instanceof Scalar || $node instanceof Blank) {
54 54
             return $this->getParent();
55 55
         } else {
56 56
             return $this->getParent($node->indent);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
  \.nan | \.NaN | \.NAN   tag:yaml.org,2002:float (Not a number)
98 98
  *   tag:yaml.org,2002:str (Default)
99 99
  */
100
-        if (Regex::isDate($v))   return ($this->getRoot()->getYamlObject()->getOptions() & Loader::NO_OBJECT_FOR_DATE) && !$onlyScalar ? date_create($v) : $v;
100
+        if (Regex::isDate($v))   return ($this->getRoot()->getYamlObject()->getOptions()&Loader::NO_OBJECT_FOR_DATE) && !$onlyScalar ? date_create($v) : $v;
101 101
         if (Regex::isNumber($v)) return $this->getNumber($v);
102 102
         $types = ['yes'   => true,
103 103
                   'no'    => false,
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
         return array_key_exists(strtolower($v), $types) ? $types[strtolower($v)] : $this->replaceSequences($v);
112 112
     }
113 113
 
114
-    public function replaceSequences($value='')
114
+    public function replaceSequences($value = '')
115 115
     {
116
-      $replaceUnicodeSeq = function ($matches) {
116
+      $replaceUnicodeSeq = function($matches) {
117 117
             return json_decode('"'.$matches[1].'"');
118 118
       };
119
-      $replaceNonPrintable = function ($matches) {
119
+      $replaceNonPrintable = function($matches) {
120 120
             // var_dump($matches[1]);
121 121
         return $matches[1]."";
122 122
       };
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -97,8 +97,12 @@  discard block
 block discarded – undo
97 97
  \.nan | \.NaN | \.NAN   tag:yaml.org,2002:float (Not a number)
98 98
  *   tag:yaml.org,2002:str (Default)
99 99
  */
100
-        if (Regex::isDate($v))   return ($this->getRoot()->getYamlObject()->getOptions() & Loader::NO_OBJECT_FOR_DATE) && !$onlyScalar ? date_create($v) : $v;
101
-        if (Regex::isNumber($v)) return $this->getNumber($v);
100
+        if (Regex::isDate($v)) {
101
+            return ($this->getRoot()->getYamlObject()->getOptions() & Loader::NO_OBJECT_FOR_DATE) && !$onlyScalar ? date_create($v) : $v;
102
+        }
103
+        if (Regex::isNumber($v)) {
104
+            return $this->getNumber($v);
105
+        }
102 106
         $types = ['yes'   => true,
103 107
                   'no'    => false,
104 108
                   'true'  => true,
@@ -142,8 +146,12 @@  discard block
 block discarded – undo
142 146
      */
143 147
     private function getNumber(string $v)
144 148
     {
145
-        if ((bool) preg_match(Regex::OCTAL_NUM, $v)) return intval(base_convert($v, 8, 10));
146
-        if ((bool) preg_match(Regex::HEX_NUM, $v))   return intval(base_convert($v, 16, 10));
149
+        if ((bool) preg_match(Regex::OCTAL_NUM, $v)) {
150
+            return intval(base_convert($v, 8, 10));
151
+        }
152
+        if ((bool) preg_match(Regex::HEX_NUM, $v)) {
153
+            return intval(base_convert($v, 16, 10));
154
+        }
147 155
         return is_bool(strpos($v, '.')) || substr_count($v, '.') > 1 ? intval($v) : floatval($v);
148 156
     }
149 157
 
Please login to merge, or discard this patch.