From a2685878bf2cd22ed6f483feda72cb44b9d47de2 Mon Sep 17 00:00:00 2001 From: Arshid Date: Sun, 7 Sep 2025 21:16:28 +0530 Subject: [PATCH 01/15] DowngradeFinalPropertyPromotionRector --- config/set/downgrade-php85.php | 2 + ...ngradeFinalPropertyPromotionRectorTest.php | 28 ++++++ .../Fixture/fixture.php.inc | 26 ++++++ .../Fixture/skip_fixture_readonly.php.inc | 12 +++ .../config/configured_rule.php | 10 +++ .../DowngradeFinalPropertyPromotionRector.php | 88 +++++++++++++++++++ 6 files changed, 166 insertions(+) create mode 100644 rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/DowngradeFinalPropertyPromotionRectorTest.php create mode 100644 rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/fixture.php.inc create mode 100644 rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/skip_fixture_readonly.php.inc create mode 100644 rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/config/configured_rule.php create mode 100644 rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php diff --git a/config/set/downgrade-php85.php b/config/set/downgrade-php85.php index 35d04acd..8863cfd5 100644 --- a/config/set/downgrade-php85.php +++ b/config/set/downgrade-php85.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Rector\Config\RectorConfig; +use Rector\DowngradePhp85\Rector\Class_\DowngradeFinalPropertyPromotionRector; use Rector\DowngradePhp85\Rector\FuncCall\DowngradeArrayFirstLastRector; use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; @@ -14,6 +15,7 @@ $rectorConfig->phpVersion(PhpVersion::PHP_84); $rectorConfig->rules([ DowngradeArrayFirstLastRector::class, + DowngradeFinalPropertyPromotionRector::class, ]); // https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_driver_specific_pdo_constants_and_methods diff --git a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/DowngradeFinalPropertyPromotionRectorTest.php b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/DowngradeFinalPropertyPromotionRectorTest.php new file mode 100644 index 00000000..c6808314 --- /dev/null +++ b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/DowngradeFinalPropertyPromotionRectorTest.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/fixture.php.inc b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/fixture.php.inc new file mode 100644 index 00000000..7896191a --- /dev/null +++ b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/fixture.php.inc @@ -0,0 +1,26 @@ + +----- + diff --git a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/skip_fixture_readonly.php.inc b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/skip_fixture_readonly.php.inc new file mode 100644 index 00000000..d99e1f91 --- /dev/null +++ b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/skip_fixture_readonly.php.inc @@ -0,0 +1,12 @@ + diff --git a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/config/configured_rule.php b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/config/configured_rule.php new file mode 100644 index 00000000..1ba08ec3 --- /dev/null +++ b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/config/configured_rule.php @@ -0,0 +1,10 @@ +rule(DowngradeFinalPropertyPromotionRector::class); +}; diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php new file mode 100644 index 00000000..28c8411b --- /dev/null +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -0,0 +1,88 @@ +> + */ + public function getNodeTypes(): array + { + return [Class_::class, Trait_::class]; + } + + /** + * @param Class_|Trait_ $node + */ + public function refactor(Node $node): null + { + $constructorClassMethod = $node->getMethod(MethodName::CONSTRUCT); + if (! $constructorClassMethod instanceof ClassMethod) { + return null; + } + + foreach ($constructorClassMethod->params as $promotedParam) { + if (($promotedParam->flags & Modifiers::FINAL) !== 0) { + $promotedParam->flags &= ~Modifiers::FINAL; + + $existingDoc = $promotedParam->getDocComment(); + if (! $existingDoc) { + $promotedParam->setDocComment(new Doc('/** @final */')); + } + } + } + + return null; + } +} From 302dc9341c76286c9b8d032f2986ac36c3342af4 Mon Sep 17 00:00:00 2001 From: Arshid Date: Mon, 8 Sep 2025 00:34:49 +0530 Subject: [PATCH 02/15] DowngradeFinalPropertyPromotionRector --- ...ngradeFinalPropertyPromotionRectorTest.php | 0 .../Fixture/fixture.php.inc | 4 +- .../Fixture/skip_fixture_readonly.php.inc | 2 +- .../config/configured_rule.php | 0 .../DowngradeFinalPropertyPromotionRector.php | 77 ++++++++++++++----- 5 files changed, 63 insertions(+), 20 deletions(-) rename rules-tests/DowngradePhp85/Rector/Class_/{DowngradeFinalPropertyPromotionRectorf => DowngradeFinalPropertyPromotionRector}/DowngradeFinalPropertyPromotionRectorTest.php (100%) rename rules-tests/DowngradePhp85/Rector/Class_/{DowngradeFinalPropertyPromotionRectorf => DowngradeFinalPropertyPromotionRector}/Fixture/fixture.php.inc (91%) rename rules-tests/DowngradePhp85/Rector/Class_/{DowngradeFinalPropertyPromotionRectorf => DowngradeFinalPropertyPromotionRector}/Fixture/skip_fixture_readonly.php.inc (88%) rename rules-tests/DowngradePhp85/Rector/Class_/{DowngradeFinalPropertyPromotionRectorf => DowngradeFinalPropertyPromotionRector}/config/configured_rule.php (100%) diff --git a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/DowngradeFinalPropertyPromotionRectorTest.php b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/DowngradeFinalPropertyPromotionRectorTest.php similarity index 100% rename from rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/DowngradeFinalPropertyPromotionRectorTest.php rename to rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/DowngradeFinalPropertyPromotionRectorTest.php diff --git a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/fixture.php.inc b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/fixture.php.inc similarity index 91% rename from rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/fixture.php.inc rename to rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/fixture.php.inc index 7896191a..d03193fd 100644 --- a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/fixture.php.inc +++ b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/fixture.php.inc @@ -18,7 +18,9 @@ namespace Rector\Tests\DowngradeFinalPropertyPromotionRector\Rector\Class_\Downg class Fixture { public function __construct( - /** @final */ + /** + * @final + */ public string $id ) {} } diff --git a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/skip_fixture_readonly.php.inc b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/skip_fixture_readonly.php.inc similarity index 88% rename from rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/skip_fixture_readonly.php.inc rename to rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/skip_fixture_readonly.php.inc index d99e1f91..a705e4fe 100644 --- a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/Fixture/skip_fixture_readonly.php.inc +++ b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/skip_fixture_readonly.php.inc @@ -2,7 +2,7 @@ namespace Rector\Tests\DowngradeFinalPropertyPromotionRector\Rector\Class_\DowngradePropertyPromotionRector\Fixture; -class Fixture +class SkipFixtureReadonly { public function __construct(readonly string $id) { diff --git a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/config/configured_rule.php b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/config/configured_rule.php similarity index 100% rename from rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRectorf/config/configured_rule.php rename to rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/config/configured_rule.php diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index 28c8411b..92d592ac 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -4,19 +4,19 @@ namespace Rector\DowngradePhp85\Rector\Class_; -use PhpParser\Comment\Doc; +use PhpParser\Builder\Property; use PhpParser\Modifiers; use PhpParser\Node; use PhpParser\Node\Param; -use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; -use PhpParser\Node\Stmt\Trait_; +use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; -use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; -use Rector\PhpParser\Node\BetterNodeFinder; -use Rector\PhpParser\Printer\BetterStandardPrinter; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; +use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\Rector\AbstractRector; use Rector\ValueObject\MethodName; +use Rector\ValueObject\Visibility; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -27,6 +27,18 @@ */ final class DowngradeFinalPropertyPromotionRector extends AbstractRector { + /** + * @var string + */ + private const TAGNAME = 'final'; + + public function __construct( + private readonly VisibilityManipulator $visibilityManipulator, + private readonly DocBlockUpdater $docBlockUpdater, + private readonly PhpDocInfoFactory $phpDocInfoFactory, + ) { + } + public function getRuleDefinition(): RuleDefinition { return new RuleDefinition('Change constructor final property promotion to @final annotation assign', [ @@ -59,30 +71,59 @@ public function __construct( */ public function getNodeTypes(): array { - return [Class_::class, Trait_::class]; + return [ClassMethod::class]; } /** - * @param Class_|Trait_ $node + * @param ClassMethod $node */ public function refactor(Node $node): null { - $constructorClassMethod = $node->getMethod(MethodName::CONSTRUCT); - if (! $constructorClassMethod instanceof ClassMethod) { + + if (! $this->isName($node, MethodName::CONSTRUCT)) { return null; } - foreach ($constructorClassMethod->params as $promotedParam) { - if (($promotedParam->flags & Modifiers::FINAL) !== 0) { - $promotedParam->flags &= ~Modifiers::FINAL; - - $existingDoc = $promotedParam->getDocComment(); - if (! $existingDoc) { - $promotedParam->setDocComment(new Doc('/** @final */')); - } + foreach ($node->params as $param) { + if (! $param->isPromoted()) { + continue; + } + if (! $this->visibilityManipulator->hasVisibility($param, Visibility::FINAL)) { + continue; } + + $this->makeNonFinal($param); + + $this->addPhpDocTag($param); + } return null; } + + public function makeNonFinal(Param $node): void + { + if (! $this->isFinal($node)) { + return; + } + + $node->flags -= Modifiers::FINAL; + } + + private function isFinal(Param $node): bool{ + return (bool) ($node->flags & Modifiers::FINAL); + } + + private function addPhpDocTag(Property|Param $node): bool + { + $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); + + if ($phpDocInfo->hasByName(self::TAGNAME)) { + return false; + } + + $phpDocInfo->addPhpDocTagNode(new PhpDocTagNode('@' . self::TAGNAME, new GenericTagValueNode(''))); + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); + return true; + } } From b4564da9f29595b1ad66f9ec409071e291ca6298 Mon Sep 17 00:00:00 2001 From: Arshid Date: Mon, 8 Sep 2025 00:35:20 +0530 Subject: [PATCH 03/15] DowngradeFinalPropertyPromotionRector --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index 92d592ac..3e8e664c 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -110,7 +110,8 @@ public function makeNonFinal(Param $node): void $node->flags -= Modifiers::FINAL; } - private function isFinal(Param $node): bool{ + private function isFinal(Param $node): bool + { return (bool) ($node->flags & Modifiers::FINAL); } From 783ff155617fd55a919aec5d05f389330719aae6 Mon Sep 17 00:00:00 2001 From: Arshid Date: Mon, 8 Sep 2025 01:00:50 +0530 Subject: [PATCH 04/15] Support Param nodes in makeNonFinal() --- .../DowngradeFinalPropertyPromotionRector.php | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index 3e8e664c..ce61890f 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -92,7 +92,7 @@ public function refactor(Node $node): null continue; } - $this->makeNonFinal($param); + $this->visibilityManipulator->makeNonFinal($param); $this->addPhpDocTag($param); @@ -101,20 +101,6 @@ public function refactor(Node $node): null return null; } - public function makeNonFinal(Param $node): void - { - if (! $this->isFinal($node)) { - return; - } - - $node->flags -= Modifiers::FINAL; - } - - private function isFinal(Param $node): bool - { - return (bool) ($node->flags & Modifiers::FINAL); - } - private function addPhpDocTag(Property|Param $node): bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); From 008d166f9e95445c047db7526328b99a22040c1c Mon Sep 17 00:00:00 2001 From: Arshid Date: Mon, 8 Sep 2025 01:11:05 +0530 Subject: [PATCH 05/15] Support Param nodes in makeNonFinal() --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index ce61890f..1220adc0 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -5,7 +5,6 @@ namespace Rector\DowngradePhp85\Rector\Class_; use PhpParser\Builder\Property; -use PhpParser\Modifiers; use PhpParser\Node; use PhpParser\Node\Param; use PhpParser\Node\Stmt\ClassMethod; @@ -88,6 +87,7 @@ public function refactor(Node $node): null if (! $param->isPromoted()) { continue; } + if (! $this->visibilityManipulator->hasVisibility($param, Visibility::FINAL)) { continue; } From 0c69706090076688cb9cf6b56f2f796176757fb8 Mon Sep 17 00:00:00 2001 From: Arshid Date: Mon, 8 Sep 2025 13:30:14 +0530 Subject: [PATCH 06/15] DowngradeFinalPropertyPromotionRector --- .../implicit_final_property_promotion.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/implicit_final_property_promotion.php diff --git a/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/implicit_final_property_promotion.php b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/implicit_final_property_promotion.php new file mode 100644 index 00000000..c048a413 --- /dev/null +++ b/rules-tests/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector/Fixture/implicit_final_property_promotion.php @@ -0,0 +1,25 @@ + +----- + Date: Mon, 8 Sep 2025 16:44:58 +0700 Subject: [PATCH 07/15] Update rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index 1220adc0..907c5c72 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -76,7 +76,7 @@ public function getNodeTypes(): array /** * @param ClassMethod $node */ - public function refactor(Node $node): null + public function refactor(Node $node): ?ClassMethod { if (! $this->isName($node, MethodName::CONSTRUCT)) { From d6d16d2197e2f6e76b611e9a990fc2ceea902bd5 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 8 Sep 2025 16:45:31 +0700 Subject: [PATCH 08/15] Update rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index 907c5c72..bbb55584 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -82,7 +82,7 @@ public function refactor(Node $node): ?ClassMethod if (! $this->isName($node, MethodName::CONSTRUCT)) { return null; } - + $hasChanged = false; foreach ($node->params as $param) { if (! $param->isPromoted()) { continue; From 9ea54848c38a876b8e447628c0cdede061b7b4aa Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 8 Sep 2025 16:46:04 +0700 Subject: [PATCH 09/15] Update rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index bbb55584..1473451b 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -91,7 +91,7 @@ public function refactor(Node $node): ?ClassMethod if (! $this->visibilityManipulator->hasVisibility($param, Visibility::FINAL)) { continue; } - + $hasChanged = true; $this->visibilityManipulator->makeNonFinal($param); $this->addPhpDocTag($param); From 61d92bb01d8770de61f30315735995c87ed4b1cb Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 8 Sep 2025 16:46:20 +0700 Subject: [PATCH 10/15] Update rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 1 - 1 file changed, 1 deletion(-) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index 1473451b..dcc2c172 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -78,7 +78,6 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?ClassMethod { - if (! $this->isName($node, MethodName::CONSTRUCT)) { return null; } From 44e5abc16112cec922895392880bf80c1493fb64 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 8 Sep 2025 16:46:51 +0700 Subject: [PATCH 11/15] Update rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index dcc2c172..9dd706dc 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -81,6 +81,7 @@ public function refactor(Node $node): ?ClassMethod if (! $this->isName($node, MethodName::CONSTRUCT)) { return null; } + $hasChanged = false; foreach ($node->params as $param) { if (! $param->isPromoted()) { From 636afa385bc52616b6c57975b9d4c0578d671d5f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 8 Sep 2025 16:47:21 +0700 Subject: [PATCH 12/15] Update rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index 9dd706dc..8c5ac00d 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -91,6 +91,7 @@ public function refactor(Node $node): ?ClassMethod if (! $this->visibilityManipulator->hasVisibility($param, Visibility::FINAL)) { continue; } + $hasChanged = true; $this->visibilityManipulator->makeNonFinal($param); From 2aa0ac9aa827a8c5f6f1638f835d834b10f548a9 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 8 Sep 2025 16:47:58 +0700 Subject: [PATCH 13/15] Update rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index 8c5ac00d..d53eb9da 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -98,7 +98,9 @@ public function refactor(Node $node): ?ClassMethod $this->addPhpDocTag($param); } - + if ($hasChanged) { + return $node; + } return null; } From 70fd6f958b50d7ffc7efb211773aadc4eea7e2be Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 8 Sep 2025 16:48:38 +0700 Subject: [PATCH 14/15] Update rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php --- .../Class_/DowngradeFinalPropertyPromotionRector.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index d53eb9da..2d87c8ca 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -98,9 +98,10 @@ public function refactor(Node $node): ?ClassMethod $this->addPhpDocTag($param); } - if ($hasChanged) { - return $node; - } + + if ($hasChanged) { + return $node; + } return null; } From 679f36f0fa88fddd0825f063148a3c35e1871aab Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 8 Sep 2025 16:49:05 +0700 Subject: [PATCH 15/15] Update rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php --- .../Rector/Class_/DowngradeFinalPropertyPromotionRector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php index 2d87c8ca..91e55a7d 100644 --- a/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php +++ b/rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php @@ -102,6 +102,7 @@ public function refactor(Node $node): ?ClassMethod if ($hasChanged) { return $node; } + return null; }