Skip to content

Commit e372f40

Browse files
committed
[perf] Skip NestedAnnotationToAttributeRector for nodes without a docblock
The rule subscribes to Property, Class_ and Param and built a PhpDocInfo for every node. The attribute groups come only from docblock doctrine annotations and it reprints an existing docblock, so a node without one always returns null. Guard the phpdoc path behind getDocComment(). Behaviour unchanged.
1 parent 359eb18 commit e372f40

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ public function getNodeTypes(): array
106106
*/
107107
public function refactor(Node $node): ?Node
108108
{
109+
// nested annotations converted to attributes only come from a docblock; skip nodes without one
110+
if ($node->getDocComment() === null) {
111+
return null;
112+
}
113+
109114
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
110115
if (! $phpDocInfo instanceof PhpDocInfo) {
111116
return null;

0 commit comments

Comments
 (0)