Passed
Push — master ( f81cc4...5281ab )
by stéphane
04:50
created
examples/write.php 2 patches
Spacing   +3 added lines, -3 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,10 +14,10 @@  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");
17
+$yamlObject = (include PROJECT_ROOT."tests/cases/dumping/$testName.php");
18 18
 $text = Yaml::dump($yamlObject, 0);
19 19
 
20
-$nameResultPair = get_object_vars(Yaml::parseFile(PROJECT_ROOT . 'tests/definitions/dumping_tests.yml'));
20
+$nameResultPair = get_object_vars(Yaml::parseFile(PROJECT_ROOT.'tests/definitions/dumping_tests.yml'));
21 21
 
22 22
 // var_dump($nameResultPair);
23 23
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,4 +24,6 @@
 block discarded – undo
24 24
 if ($nameResultPair[$testName] !== $text) {
25 25
     var_dump('EXPECTED', $nameResultPair[$testName]);
26 26
     var_dump('RECEIVED', $text);
27
-} else echo 'WRITE OK !!!';
27
+} else {
28
+    echo 'WRITE OK !!!';
29
+}
Please login to merge, or discard this patch.
sources/DumperHandlers.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             //var_dump("YAMLOBJECT");
69 69
             return $this->dumpYamlObject($compound);
70 70
         } elseif ($compound instanceof Compact) {
71
-             return $this->dumpCompact($compound, $indent);
71
+                return $this->dumpCompact($compound, $indent);
72 72
         } elseif (is_array($compound)) {
73 73
             //var_dump("ARRAY");
74 74
             $iterator = new \ArrayIterator($compound);
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
     private function dumpYamlObject(YamlObject $obj):string
98 98
     {
99 99
         if ($this->multipleDocs || $obj->hasDocStart() || $obj->isTagged()) {
100
-           $this->multipleDocs = true;
101
-          // && $this->$result instanceof DLL) $this->$result->push("---");
100
+            $this->multipleDocs = true;
101
+            // && $this->$result instanceof DLL) $this->$result->push("---");
102 102
         }
103 103
         if (count($obj) > 0) {
104 104
             //var_dump("indices");
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 
33 33
     public function dump($dataType, int $indent):string
34 34
     {
35
-        if(is_null($dataType)) {
35
+        if (is_null($dataType)) {
36 36
             return '';
37
-        } elseif(is_resource($dataType)) {
37
+        } elseif (is_resource($dataType)) {
38 38
             return get_resource_type($dataType);
39 39
         } elseif (is_scalar($dataType)) {
40 40
             return $this->dumpScalar($dataType, $indent);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             //var_dump("ARRAY");
74 74
             $iterator = new \ArrayIterator($compound);
75 75
             $mask = '-';
76
-            $refKeys = range(0, count($compound)-1);
76
+            $refKeys = range(0, count($compound) - 1);
77 77
             // var_dump("newarray",array_keys($compound), $refKeys);
78 78
             if (array_keys($compound) !== $refKeys) {
79 79
                 $mask = '%s:';
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
     }
112 112
 
113 113
 
114
-    private function iteratorToString(\Iterator $iterable, string $keyMask, int $indent, bool $isCompact=false):string
114
+    private function iteratorToString(\Iterator $iterable, string $keyMask, int $indent, bool $isCompact = false):string
115 115
     {
116 116
         $pairs = [];
117 117
         foreach ($iterable as $key => $value) {
118 118
             $separator = "\n";
119 119
             $valueIndent = $indent + self::INDENT;
120
-            if (is_scalar($value) || $value instanceof Compact || $value instanceof \DateTime ) {
120
+            if (is_scalar($value) || $value instanceof Compact || $value instanceof \DateTime) {
121 121
                 $separator   = ' ';
122 122
                 $valueIndent = 0;
123 123
             }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         if (is_array($subject) || $subject instanceof \ArrayIterator) {
146 146
             $max = count($subject);
147 147
             $objectAsArray = is_array($subject) ? $subject : $subject->getArrayCopy();
148
-            if(array_keys($objectAsArray) !== range(0, $max-1)) {
148
+            if (array_keys($objectAsArray) !== range(0, $max - 1)) {
149 149
                 $pairs = $objectAsArray;
150 150
             } else {
151 151
                 $valuesList = [];
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function __construct(int $options = null)
27 27
     {
28
-        if (is_int($options)) $this->options = $options;
28
+        if (is_int($options)) {
29
+            $this->options = $options;
30
+        }
29 31
     }
30 32
 
31 33
 
@@ -45,8 +47,12 @@  discard block
 block discarded – undo
45 47
 
46 48
     public function dumpScalar($dataType, $indent):string
47 49
     {
48
-        if ($dataType === \INF) return '.inf';
49
-        if ($dataType === -\INF) return '-.inf';
50
+        if ($dataType === \INF) {
51
+            return '.inf';
52
+        }
53
+        if ($dataType === -\INF) {
54
+            return '-.inf';
55
+        }
50 56
         $precision = "%.".$this->floatPrecision."F";
51 57
         switch (gettype($dataType)) {
52 58
             case 'boolean': return $dataType ? 'true' : 'false';
@@ -84,9 +90,13 @@  discard block
 block discarded – undo
84 90
             // $mask = '%s:';
85 91
         } elseif (is_object($compound)) {
86 92
             //var_dump("SPECIAL");
87
-            if ($compound instanceof Tagged)     return $this->dumpTagged($compound, $indent);
93
+            if ($compound instanceof Tagged) {
94
+                return $this->dumpTagged($compound, $indent);
95
+            }
88 96
             //TODO:  consider dumping datetime as date strings according to a format provided by user
89
-            if ($compound instanceof \DateTime)  return $compound->format(self::DATE_FORMAT);
97
+            if ($compound instanceof \DateTime) {
98
+                return $compound->format(self::DATE_FORMAT);
99
+            }
90 100
             // $iterator = new \ArrayIterator($compound);
91 101
             $iterator = new \ArrayIterator(get_object_vars($compound));
92 102
         }
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
                 if (!preg_match(Regex::TAG_PARTS, $this->value->raw, $matches)) {
44 44
                     throw new \UnexpectedValueException("Tag '$this->value->raw' is invalid", 1);
45 45
                 }
Please login to merge, or discard this patch.