From 7bdf603f94c827e9ecb6508710fa83556d0c6823 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 11 Apr 2026 08:53:09 +0700 Subject: [PATCH] [DeadCode] Allow remove @ var on aliased object on RemoveUselessVarTagRector --- .../Fixture/with_alias.php.inc | 32 +++++++++++++++++++ .../PhpDoc/DeadVarTagValueNodeAnalyzer.php | 4 +++ 2 files changed, 36 insertions(+) create mode 100644 rules-tests/DeadCode/Rector/Property/RemoveUselessVarTagRector/Fixture/with_alias.php.inc diff --git a/rules-tests/DeadCode/Rector/Property/RemoveUselessVarTagRector/Fixture/with_alias.php.inc b/rules-tests/DeadCode/Rector/Property/RemoveUselessVarTagRector/Fixture/with_alias.php.inc new file mode 100644 index 00000000000..3501c1e1f6c --- /dev/null +++ b/rules-tests/DeadCode/Rector/Property/RemoveUselessVarTagRector/Fixture/with_alias.php.inc @@ -0,0 +1,32 @@ + +----- + diff --git a/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php index 6cdfd81d3a8..ad4d00048c5 100644 --- a/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php @@ -84,6 +84,10 @@ public function isDead(VarTagValueNode $varTagValueNode, Property|ClassConst|Exp } if ($propertyType instanceof ObjectType && $docType instanceof ObjectType) { + if ($docType->equals($propertyType)) { + return true; + } + // more specific type is already in the property return $docType->isSuperTypeOf($propertyType) ->yes();