forked from doctrine/coding-standard
/
php80-compatibility.patch
351 lines (311 loc) · 10.7 KB
/
php80-compatibility.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index c644926..d2640a7 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -14,21 +14,22 @@ tests/input/constants-var.php 6 0
tests/input/ControlStructures.php 28 0
tests/input/doc-comment-spacing.php 11 0
tests/input/duplicate-assignment-variable.php 1 0
-tests/input/EarlyReturn.php 6 0
-tests/input/example-class.php 38 0
+tests/input/EarlyReturn.php 7 0
+tests/input/example-class.php 43 0
tests/input/forbidden-comments.php 14 0
tests/input/forbidden-functions.php 6 0
tests/input/inline_type_hint_assertions.php 7 0
tests/input/LowCaseTypes.php 2 0
tests/input/namespaces-spacing.php 7 0
-tests/input/NamingCamelCase.php 6 0
+tests/input/NamingCamelCase.php 9 0
tests/input/negation-operator.php 2 0
-tests/input/new_with_parentheses.php 18 0
+tests/input/new_with_parentheses.php 19 0
tests/input/not_spacing.php 8 0
-tests/input/null_coalesce_equal_operator.php 1 0
+tests/input/null_coalesce_equal_operator.php 5 0
tests/input/null_coalesce_operator.php 3 0
+tests/input/null_safe_operator.php 1 0
tests/input/optimized-functions.php 1 0
-tests/input/PropertyTypeHintSpacing.php 6 0
+tests/input/PropertyTypeHintSpacing.php 7 0
tests/input/return_type_on_closures.php 21 0
tests/input/return_type_on_methods.php 17 0
tests/input/semicolon_spacing.php 3 0
@@ -39,15 +40,15 @@ tests/input/superfluous-naming.php 11 0
tests/input/test-case.php 8 0
tests/input/trailing_comma_on_array.php 1 0
tests/input/traits-uses.php 11 0
-tests/input/type-hints.php 4 0
+tests/input/type-hints.php 5 0
tests/input/UnusedVariables.php 1 0
tests/input/use-ordering.php 1 0
tests/input/useless-semicolon.php 2 0
-tests/input/UselessConditions.php 20 0
+tests/input/UselessConditions.php 21 0
----------------------------------------------------------------------
-A TOTAL OF 377 ERRORS AND 0 WARNINGS WERE FOUND IN 41 FILES
+A TOTAL OF 395 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 313 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 331 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
diff --git a/tests/fixed/EarlyReturn.php b/tests/fixed/EarlyReturn.php
index 5a82a93..7d5eb01 100644
--- a/tests/fixed/EarlyReturn.php
+++ b/tests/fixed/EarlyReturn.php
@@ -11,7 +11,7 @@ class EarlyReturn
return $bar === 'bar';
}
- public function foo(): ?string
+ public function foo(): string|null
{
foreach ($itens as $item) {
if (! $item->isItem()) {
diff --git a/tests/fixed/NamingCamelCase.php b/tests/fixed/NamingCamelCase.php
index 57d9f2b..5493471 100644
--- a/tests/fixed/NamingCamelCase.php
+++ b/tests/fixed/NamingCamelCase.php
@@ -6,14 +6,11 @@ namespace Example;
class NamingCamelCase
{
- /** @var mixed */
- public $A;
+ public mixed $A;
- /** @var mixed */
- protected $B;
+ protected mixed $B;
- /** @var mixed */
- private $C;
+ private mixed $C;
public function fcn(string $A): void
{
diff --git a/tests/fixed/PropertyTypeHintSpacing.php b/tests/fixed/PropertyTypeHintSpacing.php
index 1421913..d52353c 100644
--- a/tests/fixed/PropertyTypeHintSpacing.php
+++ b/tests/fixed/PropertyTypeHintSpacing.php
@@ -9,5 +9,5 @@ final class PropertyTypeHintSpacing
public bool $boolPropertyWithDefaultValue = false;
public string $stringProperty;
public int $intProperty;
- public ?string $nullableString = null;
+ public string|null $nullableString = null;
}
diff --git a/tests/fixed/TrailingCommaOnFunctions.php b/tests/fixed/TrailingCommaOnFunctions.php
index ed304c9..001650f 100644
--- a/tests/fixed/TrailingCommaOnFunctions.php
+++ b/tests/fixed/TrailingCommaOnFunctions.php
@@ -11,7 +11,7 @@ class TrailingCommaOnFunctions
}
public function b(
- int $arg
+ int $arg,
): void {
}
}
diff --git a/tests/fixed/UselessConditions.php b/tests/fixed/UselessConditions.php
index 2151b17..71e0cfb 100644
--- a/tests/fixed/UselessConditions.php
+++ b/tests/fixed/UselessConditions.php
@@ -95,7 +95,7 @@ class UselessConditions
return false;
}
- public function nullShouldNotBeTreatedAsFalse(): ?bool
+ public function nullShouldNotBeTreatedAsFalse(): bool|null
{
if (! $this->isAdmin) {
return null;
diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php
index 998e51d..56cd902 100644
--- a/tests/fixed/example-class.php
+++ b/tests/fixed/example-class.php
@@ -25,19 +25,16 @@ class Example implements IteratorAggregate
{
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
- /** @var int|null */
- private $foo;
+ private int|null $foo = null;
/** @var string[] */
- private $bar;
+ private array $bar;
- /** @var bool */
- private $baz;
+ private bool $baz;
- /** @var ControlStructureSniff|int|string|null */
- private $baxBax;
+ private ControlStructureSniff|int|string|null $baxBax = null;
- public function __construct(?int $foo = null, array $bar = [], bool $baz = false, $baxBax = 'unused')
+ public function __construct(int|null $foo = null, array $bar = [], bool $baz = false, $baxBax = 'unused')
{
$this->foo = $foo;
$this->bar = $bar;
@@ -48,7 +45,7 @@ class Example implements IteratorAggregate
/**
* Description
*/
- public function getFoo(): ?int
+ public function getFoo(): int|null
{
return $this->foo;
}
diff --git a/tests/fixed/new_with_parentheses.php b/tests/fixed/new_with_parentheses.php
index 6e81bbe..47a06ec 100644
--- a/tests/fixed/new_with_parentheses.php
+++ b/tests/fixed/new_with_parentheses.php
@@ -24,5 +24,5 @@ $y = [new stdClass()];
$z = new stdClass() ? new stdClass() : new stdClass();
-$q = $q ?: new stdClass();
-$e = $e ?? new stdClass();
+$q = $q ?: new stdClass();
+$e ??= new stdClass();
diff --git a/tests/fixed/null_coalesce_equal_operator.php b/tests/fixed/null_coalesce_equal_operator.php
index b997469..6703d30 100644
--- a/tests/fixed/null_coalesce_equal_operator.php
+++ b/tests/fixed/null_coalesce_equal_operator.php
@@ -2,12 +2,12 @@
declare(strict_types=1);
-$bar = $bar ?? 'bar';
+$bar ??= 'bar';
-$bar['baz'] = $bar['baz'] ?? 'baz';
+$bar['baz'] ??= 'baz';
-$bar = $bar ?? 'bar';
+$bar ??= 'bar';
-$object->property = $object->property ?? 'Default Value';
+$object->property ??= 'Default Value';
-Test::$foo = Test::$foo ?? 123;
+Test::$foo ??= 123;
diff --git a/tests/fixed/null_coalesce_operator.php b/tests/fixed/null_coalesce_operator.php
index 8846dd1..51c361c 100644
--- a/tests/fixed/null_coalesce_operator.php
+++ b/tests/fixed/null_coalesce_operator.php
@@ -4,7 +4,7 @@ declare(strict_types=1);
$foo = $_GET['foo'] ?? 'foo';
-$bar = $bar ?? 'bar';
+$bar ??= 'bar';
$bar = $bar['baz'] ?? 'baz';
diff --git a/tests/fixed/null_safe_operator.php b/tests/fixed/null_safe_operator.php
index 5bbb636..7ce8a3d 100644
--- a/tests/fixed/null_safe_operator.php
+++ b/tests/fixed/null_safe_operator.php
@@ -2,4 +2,4 @@
declare(strict_types=1);
-$var = $object === null ? null : $object->property;
+$var = $object?->property;
diff --git a/tests/fixed/return_type_on_closures.php b/tests/fixed/return_type_on_closures.php
index 134bade..80ad413 100644
--- a/tests/fixed/return_type_on_closures.php
+++ b/tests/fixed/return_type_on_closures.php
@@ -22,7 +22,7 @@ static function (
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
@@ -31,7 +31,7 @@ static function (
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
@@ -40,7 +40,7 @@ static function (
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
@@ -49,7 +49,7 @@ static function (
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
@@ -58,6 +58,6 @@ static function (
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
diff --git a/tests/fixed/return_type_on_methods.php b/tests/fixed/return_type_on_methods.php
index 8e2c6f7..0c897ae 100644
--- a/tests/fixed/return_type_on_methods.php
+++ b/tests/fixed/return_type_on_methods.php
@@ -31,7 +31,7 @@ class Test
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
@@ -40,7 +40,7 @@ class Test
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
@@ -49,7 +49,7 @@ class Test
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
@@ -58,7 +58,7 @@ class Test
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
@@ -67,7 +67,7 @@ class Test
int $c,
int $d,
int $e,
- int $b
+ int $b,
): void {
}
}
diff --git a/tests/fixed/type-hints.php b/tests/fixed/type-hints.php
index 10e6f34..5e26ed8 100644
--- a/tests/fixed/type-hints.php
+++ b/tests/fixed/type-hints.php
@@ -10,7 +10,7 @@ use Traversable;
class TraversableTypeHints
{
/** @var Traversable */
- private $parameter;
+ private Traversable $parameter;
/**
* @param Iterator $iterator
@@ -25,6 +25,5 @@ class TraversableTypeHints
class UnionTypeHints
{
- /** @var int|string|null */
- private $x = 1;
+ private int|string|null $x = 1;
}
diff --git a/tests/input/TrailingCommaOnFunctions.php b/tests/input/TrailingCommaOnFunctions.php
index ed304c9..e383ee2 100644
--- a/tests/input/TrailingCommaOnFunctions.php
+++ b/tests/input/TrailingCommaOnFunctions.php
@@ -6,7 +6,7 @@ namespace Doctrine;
class TrailingCommaOnFunctions
{
- public function a(int $arg): void
+ public function a(int $arg,): void
{
}