Skip to content

Commit cb35b8f

Browse files
committed
Upgrade fixtures to PHP 8.1 and reverse patches
1 parent e64b67f commit cb35b8f

31 files changed

+1172
-1012
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ test-report: vendor
88
test-fix: vendor
99
./bin/test-fix
1010

11+
update-compatibility-patch-72:
12+
@git apply tests/php72-compatibility.patch
13+
@printf "Please open your editor and apply your changes\n"
14+
@until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved=
15+
@git diff -- tests/expected_report.txt tests/fixed tests/input > .tmp-patch && mv .tmp-patch tests/php72-compatibility.patch && git apply -R tests/php72-compatibility.patch
16+
@git commit -m 'Update compatibility patch' tests/php72-compatibility.patch
17+
1118
update-compatibility-patch-73:
1219
@git apply tests/php73-compatibility.patch
1320
@printf "Please open your editor and apply your changes\n"
@@ -29,13 +36,6 @@ update-compatibility-patch-80:
2936
@git diff -- tests/expected_report.txt tests/fixed tests/input > .tmp-patch && mv .tmp-patch tests/php80-compatibility.patch && git apply -R tests/php80-compatibility.patch
3037
@git commit -m 'Update compatibility patch' tests/php80-compatibility.patch
3138

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

tests/expected_report.txt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,26 @@ tests/input/constants-var.php 7 0
1414
tests/input/ControlStructures.php 28 0
1515
tests/input/doc-comment-spacing.php 11 0
1616
tests/input/duplicate-assignment-variable.php 1 0
17-
tests/input/EarlyReturn.php 6 0
18-
tests/input/example-class.php 38 0
17+
tests/input/EarlyReturn.php 7 0
18+
tests/input/example-class.php 43 0
19+
tests/input/ExampleBackedEnum.php 3 0
20+
tests/input/Exceptions.php 1 0
1921
tests/input/forbidden-comments.php 14 0
2022
tests/input/forbidden-functions.php 6 0
2123
tests/input/inline_type_hint_assertions.php 7 0
2224
tests/input/LowCaseTypes.php 2 0
2325
tests/input/namespaces-spacing.php 7 0
24-
tests/input/NamingCamelCase.php 6 0
26+
tests/input/NamingCamelCase.php 9 0
2527
tests/input/negation-operator.php 2 0
26-
tests/input/new_with_parentheses.php 18 0
28+
tests/input/new_with_parentheses.php 19 0
2729
tests/input/not_spacing.php 8 0
28-
tests/input/null_coalesce_equal_operator.php 1 0
30+
tests/input/null_coalesce_equal_operator.php 5 0
2931
tests/input/null_coalesce_operator.php 3 0
32+
tests/input/null_safe_operator.php 1 0
3033
tests/input/optimized-functions.php 1 0
31-
tests/input/PropertyDeclaration.php 6 0
32-
tests/input/return_type_on_closures.php 21 0
33-
tests/input/return_type_on_methods.php 17 0
34+
tests/input/PropertyDeclaration.php 14 0
35+
tests/input/return_type_on_closures.php 26 0
36+
tests/input/return_type_on_methods.php 22 0
3437
tests/input/semicolon_spacing.php 3 0
3538
tests/input/single-line-array-spacing.php 5 0
3639
tests/input/spread-operator.php 6 0
@@ -39,16 +42,17 @@ tests/input/strings.php 1 0
3942
tests/input/superfluous-naming.php 11 0
4043
tests/input/test-case.php 8 0
4144
tests/input/trailing_comma_on_array.php 1 0
45+
tests/input/TrailingCommaOnFunctions.php 6 0
4246
tests/input/traits-uses.php 11 0
43-
tests/input/type-hints.php 7 0
47+
tests/input/type-hints.php 9 0
4448
tests/input/UnusedVariables.php 1 0
4549
tests/input/use-ordering.php 1 0
4650
tests/input/useless-semicolon.php 2 0
47-
tests/input/UselessConditions.php 20 0
51+
tests/input/UselessConditions.php 21 0
4852
----------------------------------------------------------------------
49-
A TOTAL OF 382 ERRORS AND 0 WARNINGS WERE FOUND IN 42 FILES
53+
A TOTAL OF 428 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES
5054
----------------------------------------------------------------------
51-
PHPCBF CAN FIX 317 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
55+
PHPCBF CAN FIX 363 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
5256
----------------------------------------------------------------------
5357

5458

tests/fixed/ControlStructures.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function spaceBelowBlocks(): void
104104

105105
try {
106106
echo 4;
107-
} catch (Throwable $throwable) {
107+
} catch (Throwable) {
108108
}
109109

110110
echo 5;

tests/fixed/EarlyReturn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function bar(): bool
1111
return $bar === 'bar';
1212
}
1313

14-
public function foo(): ?string
14+
public function foo(): string|null
1515
{
1616
foreach ($items as $item) {
1717
if (! $item->isItem()) {

tests/fixed/ExampleBackedEnum.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
declare(strict_types=1);
44

55
namespace ExampleBackedEnum;
6+
7+
enum ExampleBackedEnum: int
8+
{
9+
}

tests/fixed/Exceptions.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@
33
declare(strict_types=1);
44

55
namespace Exceptions;
6+
7+
use Exception;
8+
use Throwable;
9+
10+
try {
11+
throw new Exception();
12+
} catch (Throwable) {
13+
}

tests/fixed/NamingCamelCase.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66

77
class NamingCamelCase
88
{
9-
/** @var mixed */
10-
public $A;
9+
public mixed $A;
1110

12-
/** @var mixed */
13-
protected $B;
11+
protected mixed $B;
1412

15-
/** @var mixed */
16-
private $C;
13+
private mixed $C;
1714

1815
public function fcn(string $A): void
1916
{

tests/fixed/PropertyDeclaration.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ final class PropertyDeclaration
99
public bool $boolPropertyWithDefaultValue = false;
1010
public string $stringProperty;
1111
public int $intProperty;
12-
public ?string $nullableString = null;
12+
public string|null $nullableString = null;
13+
14+
public function __construct(
15+
public readonly Foo $foo,
16+
) {
17+
}
1318
}

tests/fixed/TrailingCommaOnFunctions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function a(int $arg): void
1515
}
1616

1717
public function b(
18-
int $arg
18+
int $arg,
1919
): void {
2020
}
2121

@@ -28,7 +28,7 @@ public function uses(): void
2828
};
2929

3030
$multiLine = static function (int $arg) use (
31-
$var
31+
$var,
3232
): void {
3333
var_dump($var);
3434
};
@@ -37,8 +37,9 @@ public function uses(): void
3737

3838
$class = new TrailingCommaOnFunctions();
3939

40+
// phpcs:ignore Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma
4041
$class->a(1);
4142

4243
$class->a(
43-
1
44+
1,
4445
);

tests/fixed/UselessConditions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function necessaryIfConditionWithMethodCall(): bool
9595
return false;
9696
}
9797

98-
public function nullShouldNotBeTreatedAsFalse(): ?bool
98+
public function nullShouldNotBeTreatedAsFalse(): bool|null
9999
{
100100
if (! $this->isAdmin) {
101101
return null;

0 commit comments

Comments
 (0)