From 28b69c6f893bbfd0615b8dc6f5b8ee86ee03f4d3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 10 Feb 2026 17:28:57 +0700 Subject: [PATCH 1/2] [Php80] Skip property hook with indirect set on ClassPropertyAssignToConstructorPromotionRector --- .../skip_hook_with_indirect_set.php.inc | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 rules-tests/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector/Fixture/skip_hook_with_indirect_set.php.inc diff --git a/rules-tests/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector/Fixture/skip_hook_with_indirect_set.php.inc b/rules-tests/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector/Fixture/skip_hook_with_indirect_set.php.inc new file mode 100644 index 00000000000..7020c733b68 --- /dev/null +++ b/rules-tests/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector/Fixture/skip_hook_with_indirect_set.php.inc @@ -0,0 +1,25 @@ +value; + } + set { + if ($this->optionUsedInValueSetter) { + $this->value = "changed value"; + } + $this->value = $value; + } + } + + public function __construct( + mixed $value, + bool $optionUsedInValueSetter = false, + ) { + $this->value = $value; + } +} \ No newline at end of file From d64fea09f9fb2c7180eecbae631872c1753bebde Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 10 Feb 2026 17:29:22 +0700 Subject: [PATCH 2/2] Fix --- ...ClassPropertyAssignToConstructorPromotionRector.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php index bbea7ac7198..7d897abebc3 100644 --- a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php +++ b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php @@ -361,6 +361,16 @@ private function isCallableTypeIdentifier(?Node $node): bool private function shouldSkipPropertyOrParam(Property $property, Param $param): bool { + foreach ($property->hooks as $hook) { + if (! is_array($hook->body)) { + continue; + } + + if (count($hook->body) > 1) { + return true; + } + } + return $property->type instanceof Node && $param->type instanceof Node && $property->hooks !== []