forked from doctrine/coding-standard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp74-compatibility.patch
420 lines (385 loc) · 12.5 KB
/
php74-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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index d1e1fad..ed67841 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -17,26 +17,23 @@
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 7 0
-tests/input/example-class.php 47 0
-tests/input/ExampleBackedEnum.php 3 0
-tests/input/Exceptions.php 1 0
+tests/input/EarlyReturn.php 6 0
+tests/input/example-class.php 44 0
tests/input/forbidden-comments.php 14 0
tests/input/forbidden-functions.php 6 0
tests/input/inline_type_hint_assertions.php 10 0
tests/input/LowCaseTypes.php 2 0
tests/input/namespaces-spacing.php 7 0
-tests/input/NamingCamelCase.php 9 0
+tests/input/NamingCamelCase.php 6 0
tests/input/negation-operator.php 2 0
tests/input/new_with_parentheses.php 19 0
tests/input/not_spacing.php 8 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/PropertyDeclaration.php 14 0
-tests/input/return_type_on_closures.php 26 0
-tests/input/return_type_on_methods.php 22 0
+tests/input/PropertyDeclaration.php 6 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
tests/input/single-line-array-spacing.php 5 0
tests/input/spread-operator.php 6 0
@@ -46,17 +43,17 @@
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/TrailingCommaOnFunctions.php 6 0
+tests/input/TrailingCommaOnFunctions.php 2 0
tests/input/traits-uses.php 11 0
-tests/input/type-hints.php 9 0
+tests/input/type-hints.php 8 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 21 0
+tests/input/UselessConditions.php 20 0
----------------------------------------------------------------------
-A TOTAL OF 464 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES
+A TOTAL OF 428 ERRORS AND 2 WARNINGS WERE FOUND IN 47 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 380 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 344 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
diff --git a/tests/fixed/ControlStructures.php b/tests/fixed/ControlStructures.php
index f8f7f65..a653086 100644
--- a/tests/fixed/ControlStructures.php
+++ b/tests/fixed/ControlStructures.php
@@ -104,7 +104,7 @@ class ControlStructures
try {
echo 4;
- } catch (Throwable) {
+ } catch (Throwable $throwable) {
}
echo 5;
diff --git a/tests/fixed/EarlyReturn.php b/tests/fixed/EarlyReturn.php
index fc734db..caf1dbb 100644
--- a/tests/fixed/EarlyReturn.php
+++ b/tests/fixed/EarlyReturn.php
@@ -11,7 +11,7 @@ class EarlyReturn
return $bar === 'bar';
}
- public function foo(): string|null
+ public function foo(): ?string
{
foreach ($items as $item) {
if (! $item->isItem()) {
diff --git a/tests/fixed/ExampleBackedEnum.php b/tests/fixed/ExampleBackedEnum.php
index cc38c54..fe54eb9 100644
--- a/tests/fixed/ExampleBackedEnum.php
+++ b/tests/fixed/ExampleBackedEnum.php
@@ -3,7 +3,3 @@
declare(strict_types=1);
namespace ExampleBackedEnum;
-
-enum ExampleBackedEnum: int
-{
-}
diff --git a/tests/fixed/Exceptions.php b/tests/fixed/Exceptions.php
index db7408b..9b146c6 100644
--- a/tests/fixed/Exceptions.php
+++ b/tests/fixed/Exceptions.php
@@ -3,11 +3,3 @@
declare(strict_types=1);
namespace Exceptions;
-
-use Exception;
-use Throwable;
-
-try {
- throw new Exception();
-} catch (Throwable) {
-}
diff --git a/tests/fixed/NamingCamelCase.php b/tests/fixed/NamingCamelCase.php
index 5493471..57d9f2b 100644
--- a/tests/fixed/NamingCamelCase.php
+++ b/tests/fixed/NamingCamelCase.php
@@ -6,11 +6,14 @@ namespace Example;
class NamingCamelCase
{
- public mixed $A;
+ /** @var mixed */
+ public $A;
- protected mixed $B;
+ /** @var mixed */
+ protected $B;
- private mixed $C;
+ /** @var mixed */
+ private $C;
public function fcn(string $A): void
{
diff --git a/tests/fixed/PropertyDeclaration.php b/tests/fixed/PropertyDeclaration.php
index 9703897..5c3f27b 100644
--- a/tests/fixed/PropertyDeclaration.php
+++ b/tests/fixed/PropertyDeclaration.php
@@ -9,10 +9,5 @@ final class PropertyDeclaration
public bool $boolPropertyWithDefaultValue = false;
public string $stringProperty;
public int $intProperty;
- public string|null $nullableString = null;
-
- public function __construct(
- public readonly Foo $foo,
- ) {
- }
+ public ?string $nullableString = null;
}
diff --git a/tests/fixed/TrailingCommaOnFunctions.php b/tests/fixed/TrailingCommaOnFunctions.php
index 4248238..67173b3 100644
--- a/tests/fixed/TrailingCommaOnFunctions.php
+++ b/tests/fixed/TrailingCommaOnFunctions.php
@@ -15,7 +15,7 @@ class TrailingCommaOnFunctions
}
public function b(
- int $arg,
+ int $arg
): void {
}
@@ -28,7 +28,7 @@ class TrailingCommaOnFunctions
};
$multiLine = static function (int $arg) use (
- $var,
+ $var
): void {
var_dump($var);
};
diff --git a/tests/fixed/UselessConditions.php b/tests/fixed/UselessConditions.php
index 71e0cfb..2151b17 100644
--- a/tests/fixed/UselessConditions.php
+++ b/tests/fixed/UselessConditions.php
@@ -95,7 +95,7 @@ class UselessConditions
return false;
}
- public function nullShouldNotBeTreatedAsFalse(): bool|null
+ public function nullShouldNotBeTreatedAsFalse(): ?bool
{
if (! $this->isAdmin) {
return null;
diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php
index 4988dab..c31e53f 100644
--- a/tests/fixed/example-class.php
+++ b/tests/fixed/example-class.php
@@ -29,10 +29,21 @@ class Example extends ParentClass implements IteratorAggregate
{
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
- private ControlStructureSniff|int|string|null $baxBax = null;
+ private ?int $foo = null;
- public function __construct(private int|null $foo = null, private array $bar = [], private bool $baz = false, $baxBax = 'unused')
+ /** @var string[] */
+ private array $bar;
+
+ private bool $baz;
+
+ /** @var ControlStructureSniff|int|string|null */
+ private $baxBax;
+
+ public function __construct(?int $foo = null, array $bar = [], bool $baz = false, $baxBax = 'unused')
{
+ $this->foo = $foo;
+ $this->bar = $bar;
+ $this->baz = $baz;
$this->baxBax = $baxBax;
parent::__construct();
@@ -41,7 +52,7 @@ class Example extends ParentClass implements IteratorAggregate
/**
* Description
*/
- public function getFoo(): int|null
+ public function getFoo(): ?int
{
return $this->foo;
}
diff --git a/tests/fixed/null_safe_operator.php b/tests/fixed/null_safe_operator.php
index 7ce8a3d..5bbb636 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?->property;
+$var = $object === null ? null : $object->property;
diff --git a/tests/fixed/return_type_on_closures.php b/tests/fixed/return_type_on_closures.php
index 80ad413..134bade 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 0c897ae..8e2c6f7 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 5e26ed8..bfa6d4f 100644
--- a/tests/fixed/type-hints.php
+++ b/tests/fixed/type-hints.php
@@ -25,5 +25,6 @@ class TraversableTypeHints
class UnionTypeHints
{
- private int|string|null $x = 1;
+ /** @var int|string|null */
+ private $x = 1;
}
diff --git a/tests/input/ControlStructures.php b/tests/input/ControlStructures.php
index 73944e3..a0e0b2e 100644
--- a/tests/input/ControlStructures.php
+++ b/tests/input/ControlStructures.php
@@ -93,7 +93,7 @@ class ControlStructures
}
try {
echo 4;
- } catch (Throwable) {
+ } catch (Throwable $throwable) {
}
echo 5;
}
diff --git a/tests/input/ExampleBackedEnum.php b/tests/input/ExampleBackedEnum.php
index 0c47286..fe54eb9 100644
--- a/tests/input/ExampleBackedEnum.php
+++ b/tests/input/ExampleBackedEnum.php
@@ -3,7 +3,3 @@
declare(strict_types=1);
namespace ExampleBackedEnum;
-
-enum ExampleBackedEnum : int
-{
-}
diff --git a/tests/input/Exceptions.php b/tests/input/Exceptions.php
index 3aaa30f..9b146c6 100644
--- a/tests/input/Exceptions.php
+++ b/tests/input/Exceptions.php
@@ -3,11 +3,3 @@
declare(strict_types=1);
namespace Exceptions;
-
-use Exception;
-use Throwable;
-
-try {
- throw new Exception();
-} catch (Throwable $throwable) {
-}
diff --git a/tests/input/PropertyDeclaration.php b/tests/input/PropertyDeclaration.php
index acdc445..0891e12 100644
--- a/tests/input/PropertyDeclaration.php
+++ b/tests/input/PropertyDeclaration.php
@@ -10,9 +10,4 @@ final class PropertyDeclaration
public string $stringProperty;
public int $intProperty;
public ? string $nullableString = null;
-
- public function __construct(
- public readonly Foo $foo,
- ) {
- }
}
diff --git a/tests/input/TrailingCommaOnFunctions.php b/tests/input/TrailingCommaOnFunctions.php
index fc5480e..8adcedf 100644
--- a/tests/input/TrailingCommaOnFunctions.php
+++ b/tests/input/TrailingCommaOnFunctions.php
@@ -10,7 +10,7 @@ use function var_dump;
class TrailingCommaOnFunctions
{
- public function a(int $arg,): void
+ public function a(int $arg): void
{
}
@@ -23,7 +23,7 @@ class TrailingCommaOnFunctions
{
$var = null;
- $singleLine = static function (int $arg) use ($var,): void {
+ $singleLine = static function (int $arg) use ($var): void {
var_dump($var);
};