From e0e1eeda805531ccdb7d5df3fe84e0733cc48999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 20 Jul 2022 19:32:05 +0200 Subject: [PATCH] Require constructor property promotion --- lib/Doctrine/ruleset.xml | 2 ++ tests/expected_report.txt | 6 +++--- tests/fixed/example-class.php | 12 +----------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/Doctrine/ruleset.xml b/lib/Doctrine/ruleset.xml index 1a342ae0..5dddccf6 100644 --- a/lib/Doctrine/ruleset.xml +++ b/lib/Doctrine/ruleset.xml @@ -144,6 +144,8 @@ + + diff --git a/tests/expected_report.txt b/tests/expected_report.txt index d53fd480..5110131a 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 7 0 -tests/input/example-class.php 43 0 +tests/input/example-class.php 44 0 tests/input/ExampleBackedEnum.php 3 0 tests/input/Exceptions.php 1 0 tests/input/forbidden-comments.php 14 0 @@ -50,9 +50,9 @@ tests/input/use-ordering.php 1 0 tests/input/useless-semicolon.php 2 0 tests/input/UselessConditions.php 21 0 ---------------------------------------------------------------------- -A TOTAL OF 428 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES +A TOTAL OF 429 ERRORS AND 0 WARNINGS WERE FOUND IN 46 FILES ---------------------------------------------------------------------- -PHPCBF CAN FIX 363 OF THESE SNIFF VIOLATIONS AUTOMATICALLY +PHPCBF CAN FIX 364 OF THESE SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- diff --git a/tests/fixed/example-class.php b/tests/fixed/example-class.php index 56cd9024..7d278258 100644 --- a/tests/fixed/example-class.php +++ b/tests/fixed/example-class.php @@ -25,20 +25,10 @@ class Example implements IteratorAggregate { private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION; - private int|null $foo = null; - - /** @var string[] */ - private array $bar; - - private bool $baz; - private ControlStructureSniff|int|string|null $baxBax = null; - public function __construct(int|null $foo = null, array $bar = [], bool $baz = false, $baxBax = 'unused') + public function __construct(private int|null $foo = null, private array $bar = [], private bool $baz = false, $baxBax = 'unused') { - $this->foo = $foo; - $this->bar = $bar; - $this->baz = $baz; $this->baxBax = $baxBax; }