Completed
Push — 6.0 ( 34ab40 )
by Olivier
18s
created
tests/ErrorCollectionIteratorTest.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -28,24 +28,24 @@  discard block
 block discarded – undo
28 28
         $attribute = uniqid();
29 29
 
30 30
         $errors = (new ErrorCollection())
31
-            ->add($attribute, $format, [ 'arg' => $arg3 ])
32
-            ->add_generic($format, [ 'arg' => $arg1 ])
33
-            ->add($attribute, $format, [ 'arg' => $arg4 ])
34
-            ->add_generic($format, [ 'arg' => $arg2 ]);
31
+            ->add($attribute, $format, ['arg' => $arg3])
32
+            ->add_generic($format, ['arg' => $arg1])
33
+            ->add($attribute, $format, ['arg' => $arg4])
34
+            ->add_generic($format, ['arg' => $arg2]);
35 35
 
36 36
         $renderer = new ErrorCollectionIterator($errors);
37 37
         $rendered = [];
38 38
 
39 39
         foreach ($renderer as $a => $r) {
40
-            $rendered[] = [ $a, $r ];
40
+            $rendered[] = [$a, $r];
41 41
         }
42 42
 
43 43
         $this->assertSame([
44 44
 
45
-            [ ErrorCollection::GENERIC, "error: $arg1" ],
46
-            [ ErrorCollection::GENERIC, "error: $arg2" ],
47
-            [ $attribute, "error: $arg3" ],
48
-            [ $attribute, "error: $arg4" ],
45
+            [ErrorCollection::GENERIC, "error: $arg1"],
46
+            [ErrorCollection::GENERIC, "error: $arg2"],
47
+            [$attribute, "error: $arg3"],
48
+            [$attribute, "error: $arg4"],
49 49
 
50 50
         ], $rendered);
51 51
     }
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
         $attribute = uniqid();
61 61
 
62 62
         $errors = (new ErrorCollection())
63
-            ->add($attribute, $format, [ 'arg' => $arg3 ])
64
-            ->add_generic($format, [ 'arg' => $arg1 ])
65
-            ->add($attribute, $format, [ 'arg' => $arg4 ])
66
-            ->add_generic($format, [ 'arg' => $arg2 ]);
63
+            ->add($attribute, $format, ['arg' => $arg3])
64
+            ->add_generic($format, ['arg' => $arg1])
65
+            ->add($attribute, $format, ['arg' => $arg4])
66
+            ->add_generic($format, ['arg' => $arg2]);
67 67
 
68
-        $renderer = new ErrorCollectionIterator($errors, function (
68
+        $renderer = new ErrorCollectionIterator($errors, function(
69 69
             Error $error,
70 70
             $attribute,
71 71
             ErrorCollection $collection
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
         $rendered = [];
79 79
 
80 80
         foreach ($renderer as $a => $r) {
81
-            $rendered[] = [ $a, $r ];
81
+            $rendered[] = [$a, $r];
82 82
         }
83 83
 
84 84
         $this->assertSame([
85 85
 
86
-            [ ErrorCollection::GENERIC, strrev("error: $arg1") ],
87
-            [ ErrorCollection::GENERIC, strrev("error: $arg2") ],
88
-            [ $attribute, strrev("error: $arg3") ],
89
-            [ $attribute, strrev("error: $arg4") ],
86
+            [ErrorCollection::GENERIC, strrev("error: $arg1")],
87
+            [ErrorCollection::GENERIC, strrev("error: $arg2")],
88
+            [$attribute, strrev("error: $arg3")],
89
+            [$attribute, strrev("error: $arg4")],
90 90
 
91 91
         ], $rendered);
92 92
     }
Please login to merge, or discard this patch.
tests/ErrorCollectionTest.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $attribute = uniqid();
34 34
         $format = uniqid();
35
-        $args = [ uniqid() => uniqid() ];
35
+        $args = [uniqid() => uniqid()];
36 36
         $this->errors->add($attribute, $format, $args);
37 37
         $this->assertEquals(1, $this->errors->count());
38 38
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function test_add_with_true(): void
50 50
     {
51 51
         $attribute = uniqid();
52
-        $args = [ uniqid() => uniqid() ];
52
+        $args = [uniqid() => uniqid()];
53 53
         $this->errors->add($attribute, true, $args);
54 54
         $this->assertEquals(1, $this->errors->count());
55 55
 
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 
66 66
     public function test_add_with_error(): void
67 67
     {
68
-        $error = new Error(uniqid(), [ uniqid() => uniqid() ]);
68
+        $error = new Error(uniqid(), [uniqid() => uniqid()]);
69 69
         $attribute = uniqid();
70
-        $this->errors->add($attribute, $error, [ uniqid() => uniqid() ]);
70
+        $this->errors->add($attribute, $error, [uniqid() => uniqid()]);
71 71
         $this->assertEquals(1, $this->errors->count());
72 72
 
73 73
         $errors = $this->errors[$attribute];
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     {
80 80
         $error = new Exception();
81 81
         $attribute = uniqid();
82
-        $this->errors->add($attribute, $error, [ uniqid() => uniqid() ]);
82
+        $this->errors->add($attribute, $error, [uniqid() => uniqid()]);
83 83
         $this->assertEquals(1, $this->errors->count());
84 84
 
85 85
         $errors = $this->errors[$attribute];
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $error = new \Error();
95 95
         $attribute = uniqid();
96
-        $this->errors->add($attribute, $error, [ uniqid() => uniqid() ]);
96
+        $this->errors->add($attribute, $error, [uniqid() => uniqid()]);
97 97
         $this->assertEquals(1, $this->errors->count());
98 98
 
99 99
         $errors = $this->errors[$attribute];
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
     public function test_add_generic(): void
107 107
     {
108
-        $error = new Error(uniqid(), [ uniqid() => uniqid() ]);
108
+        $error = new Error(uniqid(), [uniqid() => uniqid()]);
109 109
         $this->errors->add_generic($error);
110 110
         $errors = $this->errors[null];
111 111
         $this->assertSame($error, reset($errors));
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
     public function test_array_access_interface(): void
115 115
     {
116 116
         $errors = $this->errors;
117
-        $err1 = new Error(uniqid(), [ uniqid() => uniqid() ]);
118
-        $err2 = new Error(uniqid(), [ uniqid() => uniqid() ]);
119
-        $err3 = new Error(uniqid(), [ uniqid() => uniqid() ]);
120
-        $err4 = new Error(uniqid(), [ uniqid() => uniqid() ]);
117
+        $err1 = new Error(uniqid(), [uniqid() => uniqid()]);
118
+        $err2 = new Error(uniqid(), [uniqid() => uniqid()]);
119
+        $err3 = new Error(uniqid(), [uniqid() => uniqid()]);
120
+        $err4 = new Error(uniqid(), [uniqid() => uniqid()]);
121 121
         $attribute = uniqid();
122 122
         $errors[] = $err1;
123 123
         $errors[] = $err2;
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 
127 127
         $this->assertTrue(isset($errors[null]));
128 128
         $this->assertTrue(isset($errors[$attribute]));
129
-        $this->assertSame([ $err1, $err2 ], $errors[null]);
130
-        $this->assertSame([ $err3, $err4 ], $errors[$attribute]);
129
+        $this->assertSame([$err1, $err2], $errors[null]);
130
+        $this->assertSame([$err3, $err4], $errors[$attribute]);
131 131
 
132 132
         unset($errors[null]);
133 133
         $this->assertSame([], $errors[null]);
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
     public function test_iterator(): void
139 139
     {
140 140
         $errors = $this->errors;
141
-        $err1 = new Error('err1-' . uniqid());
142
-        $err2 = new Error('err2-' . uniqid());
143
-        $err3 = new Error('err3-' . uniqid());
144
-        $err4 = new Error('err4-' . uniqid());
141
+        $err1 = new Error('err1-'.uniqid());
142
+        $err2 = new Error('err2-'.uniqid());
143
+        $err3 = new Error('err3-'.uniqid());
144
+        $err4 = new Error('err4-'.uniqid());
145 145
         $attribute = uniqid();
146 146
         $errors[$attribute] = $err3;
147 147
         $errors[] = $err1;
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
         $iterator_errors = [];
152 152
 
153 153
         foreach ($errors as $a => $e) {
154
-            $iterator_errors[] = [ $a => $e ];
154
+            $iterator_errors[] = [$a => $e];
155 155
         }
156 156
 
157 157
         $this->assertSame([
158 158
 
159
-            [ ErrorCollection::GENERIC => $err1 ],
160
-            [ ErrorCollection::GENERIC => $err2 ],
161
-            [ $attribute => $err3 ],
162
-            [ $attribute => $err4 ],
159
+            [ErrorCollection::GENERIC => $err1],
160
+            [ErrorCollection::GENERIC => $err2],
161
+            [$attribute => $err3],
162
+            [$attribute => $err4],
163 163
 
164 164
         ], $iterator_errors);
165 165
     }
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
     public function test_each(): void
168 168
     {
169 169
         $errors = $this->errors;
170
-        $err1 = new Error('err1-' . uniqid());
171
-        $err2 = new Error('err2-' . uniqid());
172
-        $err3 = new Error('err3-' . uniqid());
173
-        $err4 = new Error('err4-' . uniqid());
170
+        $err1 = new Error('err1-'.uniqid());
171
+        $err2 = new Error('err2-'.uniqid());
172
+        $err3 = new Error('err3-'.uniqid());
173
+        $err4 = new Error('err4-'.uniqid());
174 174
         $attribute = uniqid();
175 175
         $errors[$attribute] = $err3;
176 176
         $errors[] = $err1;
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 
180 180
         $iterator_errors = [];
181 181
 
182
-        $errors->each(function ($error, $attribute, $collection) use (&$iterator_errors, $errors) {
182
+        $errors->each(function($error, $attribute, $collection) use (&$iterator_errors, $errors) {
183 183
             $this->assertSame($errors, $collection);
184
-            $iterator_errors[] = [ $attribute => $error ];
184
+            $iterator_errors[] = [$attribute => $error];
185 185
         });
186 186
 
187 187
         $this->assertSame([
188 188
 
189
-            [ ErrorCollection::GENERIC => $err1 ],
190
-            [ ErrorCollection::GENERIC => $err2 ],
191
-            [ $attribute => $err3 ],
192
-            [ $attribute => $err4 ],
189
+            [ErrorCollection::GENERIC => $err1],
190
+            [ErrorCollection::GENERIC => $err2],
191
+            [$attribute => $err3],
192
+            [$attribute => $err4],
193 193
 
194 194
         ], $iterator_errors);
195 195
     }
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
         $arg4 = uniqid();
235 235
         $attribute = uniqid();
236 236
         $errors = $this->errors;
237
-        $errors->add($attribute, $format, [ 'arg' => $arg3 ]);
238
-        $errors->add_generic($format, [ 'arg' => $arg1 ]);
239
-        $errors->add($attribute, $format, [ 'arg' => $arg4 ]);
240
-        $errors->add_generic($format, [ 'arg' => $arg2 ]);
237
+        $errors->add($attribute, $format, ['arg' => $arg3]);
238
+        $errors->add_generic($format, ['arg' => $arg1]);
239
+        $errors->add($attribute, $format, ['arg' => $arg4]);
240
+        $errors->add_generic($format, ['arg' => $arg2]);
241 241
 
242 242
         $this->assertSame(json_encode([
243 243
 
Please login to merge, or discard this patch.
tests/ErrorTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
     public function test_getters(): void
20 20
     {
21 21
         $format = uniqid();
22
-        $args = [ uniqid() => uniqid() ];
22
+        $args = [uniqid() => uniqid()];
23 23
         $error = new Error($format, $args);
24 24
 
25 25
         $this->assertSame($format, $error->format);
Please login to merge, or discard this patch.
lib/ErrorCollectionIterator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
      */
34 34
     public function __construct(
35 35
         private readonly ErrorCollection $collection,
36
-        ErrorRenderer|callable $render_error = null
36
+        ErrorRenderer | callable $render_error = null
37 37
     ) {
38 38
         $this->render_error = $render_error ?? fn(Error $error) => (string) $error;
39 39
     }
Please login to merge, or discard this patch.
lib/ErrorCollection.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function add(
54 54
         string $attribute,
55
-        Throwable|bool|string|Error $error_or_format_or_true = true,
55
+        Throwable | bool | string | Error $error_or_format_or_true = true,
56 56
         array $args = []
57 57
     ): static {
58 58
         $this->assert_valid_error($error_or_format_or_true);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @return $this
75 75
      */
76 76
     public function add_generic(
77
-        Throwable|bool|string|Error $error_or_format_or_true = true,
77
+        Throwable | bool | string | Error $error_or_format_or_true = true,
78 78
         array $args = []
79 79
     ): static {
80 80
         return $this->add(self::GENERIC, $error_or_format_or_true, $args);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      * @param array<int|string, mixed> $args
111 111
      */
112 112
     private function ensure_error_instance(
113
-        Throwable|bool|string|Error $error_or_format_or_true,
113
+        Throwable | bool | string | Error $error_or_format_or_true,
114 114
         array $args = []
115 115
     ): Error {
116 116
         $error = $error_or_format_or_true;
@@ -290,6 +290,6 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public function to_array(): array
292 292
     {
293
-        return array_filter(array_merge([ self::GENERIC => [] ], $this->collection));
293
+        return array_filter(array_merge([self::GENERIC => []], $this->collection));
294 294
     }
295 295
 }
Please login to merge, or discard this patch.