Skip to content

Commit c476a86

Browse files
committed
Clean up old identifiers and metadata
1 parent 9a3ed85 commit c476a86

19 files changed

+13
-140
lines changed

src/Rules/Comparison/ElseIfConstantConditionRule.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,7 @@ public function processNode(
5454
$errorBuilder = $addTip(RuleErrorBuilder::message(sprintf(
5555
'Elseif condition is always %s.',
5656
$exprType->getValue() ? 'true' : 'false',
57-
)))->line($node->cond->getLine())
58-
->identifier('deadCode.elseifConstantCondition')
59-
->metadata([
60-
'depth' => $node->getAttribute('statementDepth'),
61-
'order' => $node->getAttribute('statementOrder'),
62-
'value' => $exprType->getValue(),
63-
]);
57+
)))->line($node->cond->getLine());
6458

6559
if ($exprType->getValue() && $isLast === false && !$this->reportAlwaysTrueInLastCondition) {
6660
$errorBuilder->tip('Remove remaining cases below this one and this error will disappear too.');

src/Rules/Comparison/IfConstantConditionRule.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,7 @@ public function processNode(
5151
$addTip(RuleErrorBuilder::message(sprintf(
5252
'If condition is always %s.',
5353
$exprType->getValue() ? 'true' : 'false',
54-
)))->line($node->cond->getLine())
55-
->identifier('deadCode.ifConstantCondition')
56-
->metadata([
57-
'depth' => $node->getAttribute('statementDepth'),
58-
'order' => $node->getAttribute('statementOrder'),
59-
'value' => $exprType->getValue(),
60-
])
61-
->build(),
54+
)))->line($node->cond->getLine())->build(),
6255
];
6356
}
6457

src/Rules/Comparison/TernaryOperatorConstantConditionRule.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,7 @@ public function processNode(
5050
$addTip(RuleErrorBuilder::message(sprintf(
5151
'Ternary operator condition is always %s.',
5252
$exprType->getValue() ? 'true' : 'false',
53-
)))
54-
->identifier('deadCode.ternaryConstantCondition')
55-
->metadata([
56-
'statementDepth' => $node->getAttribute('statementDepth'),
57-
'statementOrder' => $node->getAttribute('statementOrder'),
58-
'depth' => $node->getAttribute('expressionDepth'),
59-
'order' => $node->getAttribute('expressionOrder'),
60-
'value' => $exprType->getValue(),
61-
])
62-
->build(),
53+
)))->build(),
6354
];
6455
}
6556

src/Rules/Comparison/UnreachableIfBranchesRule.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,7 @@ public function processNode(Node $node, Scope $scope): array
5353

5454
foreach ($node->elseifs as $elseif) {
5555
if ($nextBranchIsDead) {
56-
$errors[] = $addTip(RuleErrorBuilder::message('Elseif branch is unreachable because previous condition is always true.')->line($elseif->getLine()))
57-
->identifier('deadCode.unreachableElseif')
58-
->metadata([
59-
'ifDepth' => $node->getAttribute('statementDepth'),
60-
'ifOrder' => $node->getAttribute('statementOrder'),
61-
'depth' => $elseif->getAttribute('statementDepth'),
62-
'order' => $elseif->getAttribute('statementOrder'),
63-
])
64-
->build();
56+
$errors[] = $addTip(RuleErrorBuilder::message('Elseif branch is unreachable because previous condition is always true.')->line($elseif->getLine()))->build();
6557
continue;
6658
}
6759

@@ -72,13 +64,7 @@ public function processNode(Node $node, Scope $scope): array
7264
}
7365

7466
if ($node->else !== null && $nextBranchIsDead) {
75-
$errors[] = $addTip(RuleErrorBuilder::message('Else branch is unreachable because previous condition is always true.'))->line($node->else->getLine())
76-
->identifier('deadCode.unreachableElse')
77-
->metadata([
78-
'ifDepth' => $node->getAttribute('statementDepth'),
79-
'ifOrder' => $node->getAttribute('statementOrder'),
80-
])
81-
->build();
67+
$errors[] = $addTip(RuleErrorBuilder::message('Else branch is unreachable because previous condition is always true.'))->line($node->else->getLine())->build();
8268
}
8369

8470
return $errors;

src/Rules/Comparison/UnreachableTernaryElseBranchRule.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ public function processNode(Node $node, Scope $scope): array
5555
return [
5656
$addTip(RuleErrorBuilder::message('Else branch is unreachable because ternary operator condition is always true.'))
5757
->line($node->else->getLine())
58-
->identifier('deadCode.unreachableTernaryElse')
59-
->metadata([
60-
'statementDepth' => $node->getAttribute('statementDepth'),
61-
'statementOrder' => $node->getAttribute('statementOrder'),
62-
'depth' => $node->getAttribute('expressionDepth'),
63-
'order' => $node->getAttribute('expressionOrder'),
64-
])
6558
->build(),
6659
];
6760
}

src/Rules/DeadCode/NoopRule.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ public function processNode(Node $node, Scope $scope): array
5656
'Expression "%s" on a separate line does not do anything.',
5757
$this->exprPrinter->printExpr($originalExpr),
5858
))->line($expr->getLine())
59-
->identifier('deadCode.noopExpression')
60-
->metadata([
61-
'depth' => $node->getAttribute('statementDepth'),
62-
'order' => $node->getAttribute('statementOrder'),
63-
])
6459
->build(),
6560
];
6661
}

src/Rules/DeadCode/UnreachableStatementRule.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ public function getNodeType(): string
2222
public function processNode(Node $node, Scope $scope): array
2323
{
2424
return [
25-
RuleErrorBuilder::message('Unreachable statement - code above always terminates.')
26-
->identifier('deadCode.unreachableStatement')
27-
->metadata([
28-
'depth' => $node->getAttribute('statementDepth'),
29-
'order' => $node->getAttribute('statementOrder'),
30-
])
31-
->build(),
25+
RuleErrorBuilder::message('Unreachable statement - code above always terminates.')->build(),
3226
];
3327
}
3428

src/Rules/DeadCode/UnusedPrivateConstantRule.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,6 @@ public function processNode(Node $node, Scope $scope): array
8888
foreach ($constants as $constantName => $constantNode) {
8989
$errors[] = RuleErrorBuilder::message(sprintf('Constant %s::%s is unused.', $classReflection->getDisplayName(), $constantName))
9090
->line($constantNode->getLine())
91-
->identifier('deadCode.unusedClassConstant')
92-
->metadata([
93-
'classOrder' => $node->getClass()->getAttribute('statementOrder'),
94-
'classDepth' => $node->getClass()->getAttribute('statementDepth'),
95-
'classStartLine' => $node->getClass()->getStartLine(),
96-
'constantName' => $constantName,
97-
])
9891
->tip(sprintf('See: %s', 'https://phpstan.org/developing-extensions/always-used-class-constants'))
9992
->build();
10093
}

src/Rules/DeadCode/UnusedPrivateMethodRule.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,6 @@ public function processNode(Node $node, Scope $scope): array
154154
}
155155
$errors[] = RuleErrorBuilder::message(sprintf('%s %s::%s() is unused.', $methodType, $classReflection->getDisplayName(), $methodName))
156156
->line($method->getNode()->getLine())
157-
->identifier('deadCode.unusedMethod')
158-
->metadata([
159-
'classOrder' => $node->getClass()->getAttribute('statementOrder'),
160-
'classDepth' => $node->getClass()->getAttribute('statementDepth'),
161-
'classStartLine' => $node->getClass()->getStartLine(),
162-
'methodName' => $methodName,
163-
])
164157
->build();
165158
}
166159

src/Rules/DeadCode/UnusedPrivatePropertyRule.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,6 @@ public function processNode(Node $node, Scope $scope): array
175175
if (!$data['written']) {
176176
$errors[] = RuleErrorBuilder::message(sprintf('%s is unused.', $propertyName))
177177
->line($propertyNode->getStartLine())
178-
->identifier('deadCode.unusedProperty')
179-
->metadata([
180-
'classOrder' => $node->getClass()->getAttribute('statementOrder'),
181-
'classDepth' => $node->getClass()->getAttribute('statementDepth'),
182-
'classStartLine' => $node->getClass()->getStartLine(),
183-
'propertyName' => $name,
184-
])
185178
->tip($tip)
186179
->build();
187180
} else {

0 commit comments

Comments
 (0)