Skip to content

Commit d69a8ed

Browse files
committed
Updated Rector to commit 2681751795bc580f4bab291b42cb7a6adbba03b8
rectorphp/rector-src@2681751 [DeadCode] Handle multi vars on RemoveNonExistingVarAnnotationRector (#7780)
1 parent 69f087c commit d69a8ed

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

rules/DeadCode/Rector/Node/RemoveNonExistingVarAnnotationRector.php

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function refactor(Node $node): ?Node
109109
$hasChanged = \false;
110110
$extractValues = [];
111111
foreach ($node->stmts as $key => $stmt) {
112+
$hasChangedStmt = \false;
112113
if ($stmt instanceof Expression && $stmt->expr instanceof FuncCall && $this->isName($stmt->expr, 'extract') && !$stmt->expr->isFirstClassCallable()) {
113114
$appendExtractValues = $this->valueResolver->getValue($stmt->expr->getArgs()[0]->value);
114115
if (!is_array($appendExtractValues)) {
@@ -131,31 +132,37 @@ public function refactor(Node $node): ?Node
131132
continue;
132133
}
133134
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($stmt);
134-
$varTagValueNode = $phpDocInfo->getVarTagValueNode();
135-
if (!$varTagValueNode instanceof VarTagValueNode) {
136-
continue;
137-
}
138-
if ($this->isObjectShapePseudoType($varTagValueNode)) {
139-
continue;
140-
}
141-
$variableName = ltrim($varTagValueNode->variableName, '$');
142-
if ($variableName === '' && $this->isAllowedEmptyVariableName($stmt)) {
143-
continue;
144-
}
145-
if ($this->hasVariableName($stmt, $variableName)) {
146-
continue;
147-
}
148-
$comments = $node->getComments();
149-
if (isset($comments[1])) {
150-
// skip edge case with double comment, as impossible to resolve by PHPStan doc parser
151-
continue;
135+
$varTagValueNodes = $phpDocInfo->getPhpDocNode()->getVarTagValues();
136+
foreach ($varTagValueNodes as $varTagValueNode) {
137+
if ($this->isObjectShapePseudoType($varTagValueNode)) {
138+
continue;
139+
}
140+
$variableName = ltrim($varTagValueNode->variableName, '$');
141+
if ($variableName === '' && $this->isAllowedEmptyVariableName($stmt)) {
142+
continue;
143+
}
144+
if ($this->hasVariableName($stmt, $variableName)) {
145+
continue;
146+
}
147+
$comments = $node->getComments();
148+
if (isset($comments[1])) {
149+
// skip edge case with double comment, as impossible to resolve by PHPStan doc parser
150+
continue;
151+
}
152+
if ($this->stmtsManipulator->isVariableUsedInNextStmt($node, $key + 1, $variableName)) {
153+
continue;
154+
}
155+
if ($variableName === '') {
156+
$phpDocInfo->removeByType(VarTagValueNode::class);
157+
} else {
158+
$phpDocInfo->removeByType(VarTagValueNode::class, $variableName);
159+
}
160+
$hasChangedStmt = \true;
152161
}
153-
if ($this->stmtsManipulator->isVariableUsedInNextStmt($node, $key + 1, $variableName)) {
154-
continue;
162+
if ($hasChangedStmt) {
163+
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($stmt);
164+
$hasChanged = \true;
155165
}
156-
$phpDocInfo->removeByType(VarTagValueNode::class);
157-
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($stmt);
158-
$hasChanged = \true;
159166
}
160167
if ($hasChanged) {
161168
return $node;

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = 'ee36fdd7f17a8da512450f07aa1c41455602d952';
22+
public const PACKAGE_VERSION = '2681751795bc580f4bab291b42cb7a6adbba03b8';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-01-13 14:07:13';
27+
public const RELEASE_DATE = '2026-01-13 14:09:25';
2828
/**
2929
* @var int
3030
*/

0 commit comments

Comments
 (0)