Skip to content

Commit d9bd78d

Browse files
committed
UnusedPrivatePropertyRule - identifier and metadata
1 parent 36ff373 commit d9bd78d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/Rules/DeadCode/UnusedPrivatePropertyRule.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,16 @@ public function processNode(Node $node, Scope $scope): array
189189
}
190190
if (!$data['read']) {
191191
if (!$data['written']) {
192-
$errors[] = RuleErrorBuilder::message(sprintf('%s is unused.', $propertyName))->line($propertyNode->getStartLine())->build();
192+
$errors[] = RuleErrorBuilder::message(sprintf('%s is unused.', $propertyName))
193+
->line($propertyNode->getStartLine())
194+
->identifier('deadCode.unusedProperty')
195+
->metadata([
196+
'classOrder' => $node->getClass()->getAttribute('statementOrder'),
197+
'classDepth' => $node->getClass()->getAttribute('statementDepth'),
198+
'classStartLine' => $node->getClass()->getStartLine(),
199+
'propertyName' => $name,
200+
])
201+
->build();
193202
} else {
194203
$errors[] = RuleErrorBuilder::message(sprintf('%s is never read, only written.', $propertyName))->line($propertyNode->getStartLine())->build();
195204
}

0 commit comments

Comments
 (0)