Test Failed
Push — master ( 41f581...fc4f20 )
by stéphane
13:19
created
sources/Dumper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
         self::$options = is_int($options) ? $options : self::OPTIONS;
42 42
         $dumpHandler = new DumperHandlers($options);
43 43
         if (is_scalar($dataType)) {
44
-            return "--- ".$dumpHandler->dumpScalar($dataType). self::LINEFEED ;
44
+            return "--- ".$dumpHandler->dumpScalar($dataType).self::LINEFEED;
45 45
         }
46 46
         return $dumpHandler->dump($dataType, 0);
47 47
     }
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
@@ -130,8 +130,12 @@
 block discarded – undo
130 130
         try {
131 131
             foreach ($generator as $lineNB => $lineString) {
132 132
                 $node = NodeFactory::get($lineString, $lineNB);
133
-                if ($this->_debug === 1) echo get_class($node)."\n";
134
-                if ($this->needsSpecialProcess($node, $previous)) continue;
133
+                if ($this->_debug === 1) {
134
+                    echo get_class($node)."\n";
135
+                }
136
+                if ($this->needsSpecialProcess($node, $previous)) {
137
+                    continue;
138
+                }
135 139
                 $this->_attachBlankLines($previous);
136 140
                 switch ($node->indent <=> $previous->indent) {
137 141
                     case -1: $target = $previous->getTargetOnLessIndent($node);
Please login to merge, or discard this patch.
sources/DumperHandlers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@
 block discarded – undo
190 190
         // \x20 \xA0 \x85 \u2028 \u2029
191 191
         // A A A"
192 192
         $str = json_encode(ltrim($str));
193
-        return strspn(substr($str,1,-1), "-:?{}[]#,&*!>|'\"%") > 0 ? $str : trim($str, '"');
193
+        return strspn(substr($str, 1, -1), "-:?{}[]#,&*!>|'\"%") > 0 ? $str : trim($str, '"');
194 194
     }
195 195
 
196 196
     public function dumpTagged(Tagged $obj, int $indent):string
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
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
 {
13 13
     public function build(&$parent = null)
14 14
     {
15
-        return substr(Scalar::replaceSequences(trim($this->raw)), 1,-1);
15
+        return substr(Scalar::replaceSequences(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.
sources/nodes/Scalar.php 3 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -99,35 +99,35 @@
 block discarded – undo
99 99
         if (Regex::isDate($v))   return Builder::$dateAsObject && !$onlyScalar ? date_create($v) : $v;
100 100
         if (Regex::isNumber($v)) return self::getNumber($v);
101 101
         $types = ['yes'   => true,
102
-                  'no'    => false,
103
-                  'true'  => true,
104
-                  'false' => false,
105
-                  'null'  => null,
106
-                  '.inf'  => \INF,
107
-                  '-.inf' => -\INF,
108
-                  '.nan'  => \NAN
102
+                    'no'    => false,
103
+                    'true'  => true,
104
+                    'false' => false,
105
+                    'null'  => null,
106
+                    '.inf'  => \INF,
107
+                    '-.inf' => -\INF,
108
+                    '.nan'  => \NAN
109 109
         ];
110 110
         return array_key_exists(strtolower($v), $types) ? $types[strtolower($v)] : self::replaceSequences($v);
111 111
     }
112 112
 
113 113
     public function replaceSequences($value='')
114 114
     {
115
-      $replaceUnicodeSeq = function ($matches) {
115
+        $replaceUnicodeSeq = function ($matches) {
116 116
             return json_decode('"'.$matches[1].'"');
117
-      };
118
-      $replaceNonPrintable = function ($matches) {
117
+        };
118
+        $replaceNonPrintable = function ($matches) {
119 119
             // var_dump($matches[1]);
120 120
         return $matches[1]."";
121
-      };
121
+        };
122 122
 // preg_match( "/[^\x{06F0}-\x{06F9}\x]+/u" , '۱۲۳۴۵۶۷۸۹۰' );
123
-      return preg_replace_callback_array(
124
-          [
125
-              '/((?<![\\\\])\\\\x[0-9a-f]{2})/i' => $replaceUnicodeSeq,
126
-              '/((?<![\\\\])\\\\u[0-9a-f]{4,})/i' => $replaceUnicodeSeq,
127
-              '/(\\\\b|\\\\n|\\\\t|\\\\r)/' => $replaceNonPrintable
128
-          ],
129
-          $value
130
-      );
123
+        return preg_replace_callback_array(
124
+            [
125
+                '/((?<![\\\\])\\\\x[0-9a-f]{2})/i' => $replaceUnicodeSeq,
126
+                '/((?<![\\\\])\\\\u[0-9a-f]{4,})/i' => $replaceUnicodeSeq,
127
+                '/(\\\\b|\\\\n|\\\\t|\\\\r)/' => $replaceNonPrintable
128
+            ],
129
+            $value
130
+        );
131 131
     }
132 132
 
133 133
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
     public function getTargetOnLessIndent(NodeGeneric &$node):NodeGeneric
51 51
     {
52
-        if ($node instanceof Scalar || $node instanceof Blank ) {
52
+        if ($node instanceof Scalar || $node instanceof Blank) {
53 53
             return $this->getParent();
54 54
         } else {
55 55
             return $this->getParent($node->indent);
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
         return array_key_exists(strtolower($v), $types) ? $types[strtolower($v)] : self::replaceSequences($v);
111 111
     }
112 112
 
113
-    public function replaceSequences($value='')
113
+    public function replaceSequences($value = '')
114 114
     {
115
-      $replaceUnicodeSeq = function ($matches) {
115
+      $replaceUnicodeSeq = function($matches) {
116 116
             return json_decode('"'.$matches[1].'"');
117 117
       };
118
-      $replaceNonPrintable = function ($matches) {
118
+      $replaceNonPrintable = function($matches) {
119 119
             // var_dump($matches[1]);
120 120
         return $matches[1]."";
121 121
       };
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -96,8 +96,12 @@  discard block
 block discarded – undo
96 96
  \.nan | \.NaN | \.NAN   tag:yaml.org,2002:float (Not a number)
97 97
  *   tag:yaml.org,2002:str (Default)
98 98
  */
99
-        if (Regex::isDate($v))   return Builder::$dateAsObject && !$onlyScalar ? date_create($v) : $v;
100
-        if (Regex::isNumber($v)) return self::getNumber($v);
99
+        if (Regex::isDate($v)) {
100
+            return Builder::$dateAsObject && !$onlyScalar ? date_create($v) : $v;
101
+        }
102
+        if (Regex::isNumber($v)) {
103
+            return self::getNumber($v);
104
+        }
101 105
         $types = ['yes'   => true,
102 106
                   'no'    => false,
103 107
                   'true'  => true,
@@ -141,8 +145,12 @@  discard block
 block discarded – undo
141 145
      */
142 146
     private static function getNumber(string $v)
143 147
     {
144
-        if ((bool) preg_match(Regex::OCTAL_NUM, $v)) return intval(base_convert($v, 8, 10));
145
-        if ((bool) preg_match(Regex::HEX_NUM, $v))   return intval(base_convert($v, 16, 10));
148
+        if ((bool) preg_match(Regex::OCTAL_NUM, $v)) {
149
+            return intval(base_convert($v, 8, 10));
150
+        }
151
+        if ((bool) preg_match(Regex::HEX_NUM, $v)) {
152
+            return intval(base_convert($v, 16, 10));
153
+        }
146 154
         return is_bool(strpos($v, '.')) || substr_count($v, '.') > 1 ? intval($v) : floatval($v);
147 155
     }
148 156
 
Please login to merge, or discard this patch.
examples/read.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,18 +6,18 @@
 block discarded – undo
6 6
 /**
7 7
  * Display some use cases for Yaml library
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
 
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('./tests/cases/examples/Example_2_25.yml');//var_dump($content);
17
+$content = file_get_contents('./tests/cases/examples/Example_2_25.yml'); //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
 exit(0);
Please login to merge, or discard this patch.
examples/write.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 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
 // use Dallgoot\Yaml\{Loader, Dumper};
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 // $yaml = (new Loader('./dummy.yml', null, 0))->parse();
15 15
 // var_dump($yaml);
16 16
 $testName = 'yamlObject_properties';
17
-$yamlObject = (include PROJECT_ROOT . "tests/cases/dumping/$testName.php");
18
-echo memory_get_usage() . "\n";
17
+$yamlObject = (include PROJECT_ROOT."tests/cases/dumping/$testName.php");
18
+echo memory_get_usage()."\n";
19 19
 
20 20
 $text = Yaml::dump($yamlObject, 0);
21 21
 
22
-echo memory_get_usage() . "\n";
23
-$nameResultPair = get_object_vars(/** @scrutinizer ignore-type */ Yaml::parseFile(PROJECT_ROOT . 'tests/definitions/dumping_tests.yml'));
22
+echo memory_get_usage()."\n";
23
+$nameResultPair = get_object_vars(/** @scrutinizer ignore-type */ Yaml::parseFile(PROJECT_ROOT.'tests/definitions/dumping_tests.yml'));
24 24
 
25 25
 // var_dump($nameResultPair);
26 26
 
Please login to merge, or discard this patch.