diff --git a/src/Rules/DeadCode/UnusedPrivatePropertyRule.php b/src/Rules/DeadCode/UnusedPrivatePropertyRule.php index a6797e0e48..15c8cb7ab4 100644 --- a/src/Rules/DeadCode/UnusedPrivatePropertyRule.php +++ b/src/Rules/DeadCode/UnusedPrivatePropertyRule.php @@ -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(); }