diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 67cc5e9d..3d27a7e0 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: php-version: - - "7.2" + - "7.4" steps: - name: "Checkout" @@ -52,7 +52,7 @@ jobs: strategy: matrix: php-version: - - "7.2" + - "7.4" steps: - name: "Checkout" @@ -91,8 +91,6 @@ jobs: fail-fast: false matrix: php-version: - - "7.2" - - "7.3" - "7.4" - "8.0" - "8.1" @@ -130,8 +128,6 @@ jobs: fail-fast: false matrix: php-version: - - "7.2" - - "7.3" - "7.4" - "8.0" - "8.1" diff --git a/Makefile b/Makefile index 43a08501..c1fef36d 100644 --- a/Makefile +++ b/Makefile @@ -10,20 +10,6 @@ test-report: vendor test-fix: vendor ./bin/test-fix -update-compatibility-patch-72: - @git apply tests/php72-compatibility.patch - @printf "Please open your editor and apply your changes\n" - @until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved= - @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 - @git commit -m 'Update compatibility patch' tests/php72-compatibility.patch - -update-compatibility-patch-73: - @git apply tests/php73-compatibility.patch - @printf "Please open your editor and apply your changes\n" - @until [ "$${compatibility_resolved}" == "y" ]; do read -p "Have finished your changes (y|n)? " compatibility_resolved; done && compatibility_resolved= - @git diff -- tests/expected_report.txt tests/fixed tests/input > .tmp-patch && mv .tmp-patch tests/php73-compatibility.patch && git apply -R tests/php73-compatibility.patch - @git commit -m 'Update compatibility patch' tests/php73-compatibility.patch - update-compatibility-patch-74: @git apply tests/php74-compatibility.patch @printf "Please open your editor and apply your changes\n" diff --git a/composer.json b/composer.json index 1eda226e..119158b1 100644 --- a/composer.json +++ b/composer.json @@ -22,9 +22,9 @@ {"name": "Steve Müller", "email": "st.mueller@dzh-online.de"} ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0.0", - "slevomat/coding-standard": "^8.14", + "slevomat/coding-standard": "^8.16", "squizlabs/php_codesniffer": "^3.7" }, "config": { diff --git a/lib/Doctrine/ruleset.xml b/lib/Doctrine/ruleset.xml index ce8383c7..ec87e514 100644 --- a/lib/Doctrine/ruleset.xml +++ b/lib/Doctrine/ruleset.xml @@ -482,10 +482,11 @@ - - + + - + + diff --git a/tests/expected_report.txt b/tests/expected_report.txt index 087995d9..5cc438a8 100644 --- a/tests/expected_report.txt +++ b/tests/expected_report.txt @@ -5,7 +5,7 @@ FILE ERRORS WARNINGS ---------------------------------------------------------------------- tests/input/annotation-name.php 8 0 tests/input/array_indentation.php 10 0 -tests/input/arrow-functions-format.php 10 0 +tests/input/arrow-functions-format.php 12 0 tests/input/assignment-operators.php 4 0 tests/input/attributes.php 15 0 tests/input/binary_operators.php 9 0 @@ -54,9 +54,9 @@ tests/input/use-ordering.php 1 0 tests/input/useless-semicolon.php 2 0 tests/input/UselessConditions.php 21 0 ---------------------------------------------------------------------- -A TOTAL OF 464 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES +A TOTAL OF 466 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES ---------------------------------------------------------------------- -PHPCBF CAN FIX 380 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 382 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/fixed/arrow-functions-format.php b/tests/fixed/arrow-functions-format.php index 4da39b82..dcb5a3ed 100644 --- a/tests/fixed/arrow-functions-format.php +++ b/tests/fixed/arrow-functions-format.php @@ -32,12 +32,12 @@ ]; $singleLineArrayReturn = Collection::map( - static fn () => [1, 2] + static fn () => [1, 2], ); $wrongMultiLineArrayReturn = Collection::map( static fn () => [ 1, 2, - ] + ], ); diff --git a/tests/php72-compatibility.patch b/tests/php72-compatibility.patch deleted file mode 100644 index e39c9728..00000000 --- a/tests/php72-compatibility.patch +++ /dev/null @@ -1,572 +0,0 @@ -diff --git a/tests/expected_report.txt b/tests/expected_report.txt -index 087995d..84c9474 100644 ---- a/tests/expected_report.txt -+++ b/tests/expected_report.txt -@@ -17,26 +17,23 @@ 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 7 0 --tests/input/example-class.php 47 0 --tests/input/ExampleBackedEnum.php 5 0 --tests/input/Exceptions.php 1 0 -+tests/input/EarlyReturn.php 6 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 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/new_with_parentheses.php 18 0 - tests/input/not_spacing.php 8 0 --tests/input/null_coalesce_equal_operator.php 5 0 -+tests/input/null_coalesce_equal_operator.php 1 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,16 @@ tests/input/strings.php 3 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/TrailingCommaOnFunctions.php 6 0 - tests/input/traits-uses.php 11 0 --tests/input/type-hints.php 9 0 -+tests/input/type-hints.php 7 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 415 ERRORS AND 2 WARNINGS WERE FOUND IN 46 FILES - ---------------------------------------------------------------------- --PHPCBF CAN FIX 380 OF THESE SNIFF VIOLATIONS AUTOMATICALLY -+PHPCBF CAN FIX 331 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 fd701eb..fe54eb9 100644 ---- a/tests/fixed/ExampleBackedEnum.php -+++ b/tests/fixed/ExampleBackedEnum.php -@@ -3,14 +3,3 @@ - declare(strict_types=1); - - namespace ExampleBackedEnum; -- --enum ExampleBackedEnum: int --{ -- case FOO = 0; -- case BAR = 1; -- -- case BAZ = 2; -- -- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */ -- case BAM = 1234; --} -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..f3ffa91 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); - }; -@@ -37,9 +37,8 @@ class TrailingCommaOnFunctions - - $class = new TrailingCommaOnFunctions(); - --// phpcs:ignore Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma - $class->a(1); - - $class->a( -- 1, -+ 1 - ); -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/arrow-functions-format.php b/tests/fixed/arrow-functions-format.php -index 4da39b8..a45074f 100644 ---- a/tests/fixed/arrow-functions-format.php -+++ b/tests/fixed/arrow-functions-format.php -@@ -18,10 +18,10 @@ $returningObject = static fn () => new stdClass(); - - $multiLineArrowFunctions = Collection::from([1, 2]) - ->map( -- static fn (int $v): int => $v * 2, -+ static fn (int $v): int => $v * 2 - ) - ->reduce( -- static fn (int $tmp, int $v): int => $tmp + $v, -+ static fn (int $tmp, int $v): int => $tmp + $v - ); - - $thisIsNotAnArrowFunction = [$this->fn => 'value']; -diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php -index 4988dab..2df56a0 100644 ---- a/tests/fixed/example-class.php -+++ b/tests/fixed/example-class.php -@@ -29,10 +29,23 @@ 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; -+ /** @var int|null */ -+ private $foo; - -- public function __construct(private int|null $foo = null, private array $bar = [], private bool $baz = false, $baxBax = 'unused') -+ /** @var string[] */ -+ private $bar; -+ -+ /** @var bool */ -+ private $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 +54,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/namespaces-spacing.php b/tests/fixed/namespaces-spacing.php -index 36cbae2..d42bbfe 100644 ---- a/tests/fixed/namespaces-spacing.php -+++ b/tests/fixed/namespaces-spacing.php -@@ -16,5 +16,5 @@ use const DATE_RFC3339; - strrev( - (new DateTimeImmutable('@' . time(), new DateTimeZone('UTC'))) - ->sub(new DateInterval('P1D')) -- ->format(DATE_RFC3339), -+ ->format(DATE_RFC3339) - ); -diff --git a/tests/fixed/new_with_parentheses.php b/tests/fixed/new_with_parentheses.php -index 47a06ec..6e81bbe 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 ??= new stdClass(); -+$q = $q ?: new stdClass(); -+$e = $e ?? new stdClass(); -diff --git a/tests/fixed/null_coalesce_equal_operator.php b/tests/fixed/null_coalesce_equal_operator.php -index 6703d30..b997469 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'] ??= 'baz'; -+$bar['baz'] = $bar['baz'] ?? 'baz'; - --$bar ??= 'bar'; -+$bar = $bar ?? 'bar'; - --$object->property ??= 'Default Value'; -+$object->property = $object->property ?? 'Default Value'; - --Test::$foo ??= 123; -+Test::$foo = Test::$foo ?? 123; -diff --git a/tests/fixed/null_coalesce_operator.php b/tests/fixed/null_coalesce_operator.php -index 51c361c..8846dd1 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 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..10e6f34 100644 ---- a/tests/fixed/type-hints.php -+++ b/tests/fixed/type-hints.php -@@ -10,7 +10,7 @@ use Traversable; - class TraversableTypeHints - { - /** @var Traversable */ -- private Traversable $parameter; -+ private $parameter; - - /** - * @param Iterator $iterator -@@ -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 3b09f47..fe54eb9 100644 ---- a/tests/input/ExampleBackedEnum.php -+++ b/tests/input/ExampleBackedEnum.php -@@ -3,16 +3,3 @@ - declare(strict_types=1); - - namespace ExampleBackedEnum; -- --enum ExampleBackedEnum : int --{ -- case FOO = 0; -- case BAR = 1; -- -- -- case BAZ = 2; -- -- -- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */ -- case BAM = 1234; --} -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..f3ffa91 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); - }; - -@@ -37,8 +37,7 @@ class TrailingCommaOnFunctions - - $class = new TrailingCommaOnFunctions(); - --// phpcs:ignore Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma --$class->a(1,); -+$class->a(1); - - $class->a( - 1 -diff --git a/tests/input/arrow-functions-format.php b/tests/input/arrow-functions-format.php -index d3903ff..8a358e8 100644 ---- a/tests/input/arrow-functions-format.php -+++ b/tests/input/arrow-functions-format.php -@@ -18,10 +18,10 @@ $returningObject = static fn () => new stdClass(); - - $multiLineArrowFunctions = Collection::from([1, 2]) - ->map( -- static fn (int $v): int => $v * 2, -+ static fn (int $v): int => $v * 2 - ) - ->reduce( -- static fn (int $tmp, int $v): int => $tmp + $v, -+ static fn (int $tmp, int $v): int => $tmp + $v - ); - - $thisIsNotAnArrowFunction = [$this->fn => 'value']; -diff --git a/tests/input/namespaces-spacing.php b/tests/input/namespaces-spacing.php -index e7be018..e1ab639 100644 ---- a/tests/input/namespaces-spacing.php -+++ b/tests/input/namespaces-spacing.php -@@ -11,5 +11,5 @@ use const DATE_RFC3339; - strrev( - (new DateTimeImmutable('@' . time(), new DateTimeZone('UTC'))) - ->sub(new DateInterval('P1D')) -- ->format(DATE_RFC3339), -+ ->format(DATE_RFC3339) - ); diff --git a/tests/php73-compatibility.patch b/tests/php73-compatibility.patch deleted file mode 100644 index e8ad6e65..00000000 --- a/tests/php73-compatibility.patch +++ /dev/null @@ -1,496 +0,0 @@ -diff --git a/tests/expected_report.txt b/tests/expected_report.txt -index 087995d..cd61b3f 100644 ---- a/tests/expected_report.txt -+++ b/tests/expected_report.txt -@@ -17,26 +17,23 @@ 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 7 0 --tests/input/example-class.php 47 0 --tests/input/ExampleBackedEnum.php 5 0 --tests/input/Exceptions.php 1 0 -+tests/input/EarlyReturn.php 6 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 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/new_with_parentheses.php 18 0 - tests/input/not_spacing.php 8 0 --tests/input/null_coalesce_equal_operator.php 5 0 -+tests/input/null_coalesce_equal_operator.php 1 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/strings.php 3 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/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 7 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 417 ERRORS AND 2 WARNINGS WERE FOUND IN 47 FILES - ---------------------------------------------------------------------- --PHPCBF CAN FIX 380 OF THESE SNIFF VIOLATIONS AUTOMATICALLY -+PHPCBF CAN FIX 333 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 fd701eb..fe54eb9 100644 ---- a/tests/fixed/ExampleBackedEnum.php -+++ b/tests/fixed/ExampleBackedEnum.php -@@ -3,14 +3,3 @@ - declare(strict_types=1); - - namespace ExampleBackedEnum; -- --enum ExampleBackedEnum: int --{ -- case FOO = 0; -- case BAR = 1; -- -- case BAZ = 2; -- -- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */ -- case BAM = 1234; --} -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..2df56a0 100644 ---- a/tests/fixed/example-class.php -+++ b/tests/fixed/example-class.php -@@ -29,10 +29,23 @@ 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; -+ /** @var int|null */ -+ private $foo; - -- public function __construct(private int|null $foo = null, private array $bar = [], private bool $baz = false, $baxBax = 'unused') -+ /** @var string[] */ -+ private $bar; -+ -+ /** @var bool */ -+ private $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 +54,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/new_with_parentheses.php b/tests/fixed/new_with_parentheses.php -index 47a06ec..6e81bbe 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 ??= new stdClass(); -+$q = $q ?: new stdClass(); -+$e = $e ?? new stdClass(); -diff --git a/tests/fixed/null_coalesce_equal_operator.php b/tests/fixed/null_coalesce_equal_operator.php -index 6703d30..b997469 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'] ??= 'baz'; -+$bar['baz'] = $bar['baz'] ?? 'baz'; - --$bar ??= 'bar'; -+$bar = $bar ?? 'bar'; - --$object->property ??= 'Default Value'; -+$object->property = $object->property ?? 'Default Value'; - --Test::$foo ??= 123; -+Test::$foo = Test::$foo ?? 123; -diff --git a/tests/fixed/null_coalesce_operator.php b/tests/fixed/null_coalesce_operator.php -index 51c361c..8846dd1 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 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..10e6f34 100644 ---- a/tests/fixed/type-hints.php -+++ b/tests/fixed/type-hints.php -@@ -10,7 +10,7 @@ use Traversable; - class TraversableTypeHints - { - /** @var Traversable */ -- private Traversable $parameter; -+ private $parameter; - - /** - * @param Iterator $iterator -@@ -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 3b09f47..fe54eb9 100644 ---- a/tests/input/ExampleBackedEnum.php -+++ b/tests/input/ExampleBackedEnum.php -@@ -3,16 +3,3 @@ - declare(strict_types=1); - - namespace ExampleBackedEnum; -- --enum ExampleBackedEnum : int --{ -- case FOO = 0; -- case BAR = 1; -- -- -- case BAZ = 2; -- -- -- /** Brevis, primus coordinataes foris promissio de varius, barbatus heuretes. */ -- case BAM = 1234; --} -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); - }; - diff --git a/tests/php74-compatibility.patch b/tests/php74-compatibility.patch index b63e6b56..625e73f6 100644 --- a/tests/php74-compatibility.patch +++ b/tests/php74-compatibility.patch @@ -50,11 +50,11 @@ index 087995d..5284a56 100644 -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 426 ERRORS AND 2 WARNINGS WERE FOUND IN 47 FILES +-A TOTAL OF 466 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 342 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +-PHPCBF CAN FIX 382 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ++PHPCBF CAN FIX 344 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/php80-compatibility.patch b/tests/php80-compatibility.patch index 282cd6f9..ee61ce14 100644 --- a/tests/php80-compatibility.patch +++ b/tests/php80-compatibility.patch @@ -23,11 +23,11 @@ index 087995d..f99aa86 100644 tests/input/useless-semicolon.php 2 0 tests/input/UselessConditions.php 21 0 ---------------------------------------------------------------------- --A TOTAL OF 464 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES -+A TOTAL OF 456 ERRORS AND 2 WARNINGS WERE FOUND IN 49 FILES +-A TOTAL OF 466 ERRORS AND 2 WARNINGS WERE FOUND IN 50 FILES ++A TOTAL OF 458 ERRORS AND 2 WARNINGS WERE FOUND IN 49 FILES ---------------------------------------------------------------------- --PHPCBF CAN FIX 380 OF THESE SNIFF VIOLATIONS AUTOMATICALLY -+PHPCBF CAN FIX 372 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +-PHPCBF CAN FIX 382 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ++PHPCBF CAN FIX 374 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ----------------------------------------------------------------------