/
php74-compatibility.patch
131 lines (112 loc) · 5.25 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
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
index c644926..7d122d2 100644
--- a/tests/expected_report.txt
+++ b/tests/expected_report.txt
@@ -15,7 +15,7 @@ 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/example-class.php 41 0
tests/input/forbidden-comments.php 14 0
tests/input/forbidden-functions.php 6 0
tests/input/inline_type_hint_assertions.php 7 0
@@ -23,9 +23,9 @@ tests/input/LowCaseTypes.php 2 0
tests/input/namespaces-spacing.php 7 0
tests/input/NamingCamelCase.php 6 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/optimized-functions.php 1 0
tests/input/PropertyDeclaration.php 6 0
@@ -35,20 +35,20 @@ tests/input/semicolon_spacing.php 3 0
tests/input/single-line-array-spacing.php 5 0
tests/input/spread-operator.php 6 0
tests/input/static-closures.php 1 0
tests/input/strings.php 1 0
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 7 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 20 0
----------------------------------------------------------------------
-A TOTAL OF 381 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
+A TOTAL OF 390 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
----------------------------------------------------------------------
-PHPCBF CAN FIX 315 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX 324 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php
index 998e51d..7866379 100644
--- a/tests/fixed/example-class.php
+++ b/tests/fixed/example-class.php
@@ -25,14 +25,12 @@ class Example implements IteratorAggregate
{
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
- /** @var int|null */
- private $foo;
+ private ?int $foo = null;
/** @var string[] */
- private $bar;
+ private array $bar;
- /** @var bool */
- private $baz;
+ private bool $baz;
/** @var ControlStructureSniff|int|string|null */
private $baxBax;
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/type-hints.php b/tests/fixed/type-hints.php
index 10e6f34..bfa6d4f 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