Skip to content

Commit 1869e36

Browse files
authored
Merge pull request #265 from simPod/test-php8
ci: run checks on php 8.0 and 8.1
2 parents f86c16a + d883bb4 commit 1869e36

File tree

3 files changed

+175
-0
lines changed

3 files changed

+175
-0
lines changed

.github/workflows/continuous-integration.yml

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ jobs:
9494
- "7.2"
9595
- "7.3"
9696
- "7.4"
97+
- "8.0"
98+
- "8.1"
9799

98100
steps:
99101
- name: "Checkout"
@@ -129,6 +131,7 @@ jobs:
129131
- "7.1"
130132
- "7.4"
131133
- "8.0"
134+
- "8.1"
132135

133136
steps:
134137
- name: "Checkout"

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ update-compatibility-patch-80:
3131
@git diff -- tests/expected_report.txt tests/fixed > .tmp-patch-80 && mv .tmp-patch-80 tests/php80-compatibility.patch && git apply -R tests/php80-compatibility.patch
3232
@git commit -m 'Update compatibility patch' tests/php80-compatibility.patch
3333

34+
update-compatibility-patch-81:
35+
@git apply tests/php81-compatibility.patch
36+
@printf "Please open your editor and apply your changes\n"
37+
@until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved=
38+
@git diff -- tests/expected_report.txt tests/fixed > .tmp-patch-81 && mv .tmp-patch-80 tests/php81-compatibility.patch && git apply -R tests/php81-compatibility.patch
39+
@git commit -m 'Update compatibility patch' tests/php81-compatibility.patch
40+
3441
vendor: composer.json
3542
composer update
3643
touch -c vendor

tests/php81-compatibility.patch

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
diff --git a/tests/expected_report.txt b/tests/expected_report.txt
2+
index c644926..d0f0a44 100644
3+
--- a/tests/expected_report.txt
4+
+++ b/tests/expected_report.txt
5+
@@ -15,18 +15,19 @@ tests/input/ControlStructures.php 28 0
6+
tests/input/doc-comment-spacing.php 11 0
7+
tests/input/duplicate-assignment-variable.php 1 0
8+
tests/input/EarlyReturn.php 6 0
9+
-tests/input/example-class.php 38 0
10+
+tests/input/example-class.php 42 0
11+
tests/input/forbidden-comments.php 14 0
12+
tests/input/forbidden-functions.php 6 0
13+
tests/input/inline_type_hint_assertions.php 7 0
14+
tests/input/LowCaseTypes.php 2 0
15+
tests/input/namespaces-spacing.php 7 0
16+
-tests/input/NamingCamelCase.php 6 0
17+
+tests/input/NamingCamelCase.php 9 0
18+
tests/input/negation-operator.php 2 0
19+
-tests/input/new_with_parentheses.php 18 0
20+
+tests/input/new_with_parentheses.php 19 0
21+
tests/input/not_spacing.php 8 0
22+
-tests/input/null_coalesce_equal_operator.php 1 0
23+
+tests/input/null_coalesce_equal_operator.php 5 0
24+
tests/input/null_coalesce_operator.php 3 0
25+
+tests/input/null_safe_operator.php 1 0
26+
tests/input/optimized-functions.php 1 0
27+
tests/input/PropertyTypeHintSpacing.php 6 0
28+
tests/input/return_type_on_closures.php 21 0
29+
@@ -39,15 +40,15 @@ tests/input/superfluous-naming.php 11 0
30+
tests/input/test-case.php 8 0
31+
tests/input/trailing_comma_on_array.php 1 0
32+
tests/input/traits-uses.php 11 0
33+
-tests/input/type-hints.php 4 0
34+
+tests/input/type-hints.php 5 0
35+
tests/input/UnusedVariables.php 1 0
36+
tests/input/use-ordering.php 1 0
37+
tests/input/useless-semicolon.php 2 0
38+
tests/input/UselessConditions.php 20 0
39+
----------------------------------------------------------------------
40+
-A TOTAL OF 377 ERRORS AND 0 WARNINGS WERE FOUND IN 41 FILES
41+
+A TOTAL OF 391 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
42+
----------------------------------------------------------------------
43+
-PHPCBF CAN FIX 313 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
44+
+PHPCBF CAN FIX 327 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
45+
----------------------------------------------------------------------
46+
47+
48+
diff --git a/tests/fixed/NamingCamelCase.php b/tests/fixed/NamingCamelCase.php
49+
index 57d9f2b..5493471 100644
50+
--- a/tests/fixed/NamingCamelCase.php
51+
+++ b/tests/fixed/NamingCamelCase.php
52+
@@ -6,14 +6,11 @@ namespace Example;
53+
54+
class NamingCamelCase
55+
{
56+
- /** @var mixed */
57+
- public $A;
58+
+ public mixed $A;
59+
60+
- /** @var mixed */
61+
- protected $B;
62+
+ protected mixed $B;
63+
64+
- /** @var mixed */
65+
- private $C;
66+
+ private mixed $C;
67+
68+
public function fcn(string $A): void
69+
{
70+
diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php
71+
index 998e51d..b47d358 100644
72+
--- a/tests/fixed/example-class.php
73+
+++ b/tests/fixed/example-class.php
74+
@@ -25,17 +25,14 @@ class Example implements IteratorAggregate
75+
{
76+
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;
77+
78+
- /** @var int|null */
79+
- private $foo;
80+
+ private ?int $foo = null;
81+
82+
/** @var string[] */
83+
- private $bar;
84+
+ private array $bar;
85+
86+
- /** @var bool */
87+
- private $baz;
88+
+ private bool $baz;
89+
90+
- /** @var ControlStructureSniff|int|string|null */
91+
- private $baxBax;
92+
+ private ControlStructureSniff|int|string|null $baxBax = null;
93+
94+
public function __construct(?int $foo = null, array $bar = [], bool $baz = false, $baxBax = 'unused')
95+
{
96+
diff --git a/tests/fixed/new_with_parentheses.php b/tests/fixed/new_with_parentheses.php
97+
index 6e81bbe..47a06ec 100644
98+
--- a/tests/fixed/new_with_parentheses.php
99+
+++ b/tests/fixed/new_with_parentheses.php
100+
@@ -24,5 +24,5 @@ $y = [new stdClass()];
101+
102+
$z = new stdClass() ? new stdClass() : new stdClass();
103+
104+
-$q = $q ?: new stdClass();
105+
-$e = $e ?? new stdClass();
106+
+$q = $q ?: new stdClass();
107+
+$e ??= new stdClass();
108+
diff --git a/tests/fixed/null_coalesce_equal_operator.php b/tests/fixed/null_coalesce_equal_operator.php
109+
index b997469..6703d30 100644
110+
--- a/tests/fixed/null_coalesce_equal_operator.php
111+
+++ b/tests/fixed/null_coalesce_equal_operator.php
112+
@@ -2,12 +2,12 @@
113+
114+
declare(strict_types=1);
115+
116+
-$bar = $bar ?? 'bar';
117+
+$bar ??= 'bar';
118+
119+
-$bar['baz'] = $bar['baz'] ?? 'baz';
120+
+$bar['baz'] ??= 'baz';
121+
122+
-$bar = $bar ?? 'bar';
123+
+$bar ??= 'bar';
124+
125+
-$object->property = $object->property ?? 'Default Value';
126+
+$object->property ??= 'Default Value';
127+
128+
-Test::$foo = Test::$foo ?? 123;
129+
+Test::$foo ??= 123;
130+
diff --git a/tests/fixed/null_coalesce_operator.php b/tests/fixed/null_coalesce_operator.php
131+
index 8846dd1..51c361c 100644
132+
--- a/tests/fixed/null_coalesce_operator.php
133+
+++ b/tests/fixed/null_coalesce_operator.php
134+
@@ -4,7 +4,7 @@ declare(strict_types=1);
135+
136+
$foo = $_GET['foo'] ?? 'foo';
137+
138+
-$bar = $bar ?? 'bar';
139+
+$bar ??= 'bar';
140+
141+
$bar = $bar['baz'] ?? 'baz';
142+
143+
diff --git a/tests/fixed/null_safe_operator.php b/tests/fixed/null_safe_operator.php
144+
index 5bbb636..7ce8a3d 100644
145+
--- a/tests/fixed/null_safe_operator.php
146+
+++ b/tests/fixed/null_safe_operator.php
147+
@@ -2,4 +2,4 @@
148+
149+
declare(strict_types=1);
150+
151+
-$var = $object === null ? null : $object->property;
152+
+$var = $object?->property;
153+
diff --git a/tests/fixed/type-hints.php b/tests/fixed/type-hints.php
154+
index 0e952fc..9824fb0 100644
155+
--- a/tests/fixed/type-hints.php
156+
+++ b/tests/fixed/type-hints.php
157+
@@ -10,7 +10,7 @@ use Traversable;
158+
class TraversableTypeHints
159+
{
160+
/** @var Traversable */
161+
- private $parameter;
162+
+ private Traversable $parameter;
163+
164+
/**
165+
* @param Iterator $iterator

0 commit comments

Comments
 (0)