Skip to content

Commit

Permalink
UnusedPrivatePropertyRule - identifier and metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 17, 2020
1 parent 36ff373 commit d9bd78d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Rules/DeadCode/UnusedPrivatePropertyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,16 @@ public function processNode(Node $node, Scope $scope): array
}
if (!$data['read']) {
if (!$data['written']) {
$errors[] = RuleErrorBuilder::message(sprintf('%s is unused.', $propertyName))->line($propertyNode->getStartLine())->build();
$errors[] = RuleErrorBuilder::message(sprintf('%s is unused.', $propertyName))
->line($propertyNode->getStartLine())
->identifier('deadCode.unusedProperty')
->metadata([
'classOrder' => $node->getClass()->getAttribute('statementOrder'),
'classDepth' => $node->getClass()->getAttribute('statementDepth'),
'classStartLine' => $node->getClass()->getStartLine(),
'propertyName' => $name,
])
->build();
} else {
$errors[] = RuleErrorBuilder::message(sprintf('%s is never read, only written.', $propertyName))->line($propertyNode->getStartLine())->build();
}
Expand Down

0 comments on commit d9bd78d

Please sign in to comment.