Skip to content

Commit 0c985e4

Browse files
[perf] Skip AnnotationToAttributeRector for nodes without a docblock (#8627)
Co-authored-by: GitHub Action <actions@github.com>
1 parent 26d724a commit 0c985e4

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎rules/Php80/Rector/Class_/AnnotationToAttributeRector.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\Php80\Rector\Class_;
66

7+
use PhpParser\Comment\Doc;
78
use PhpParser\Node;
89
use PhpParser\Node\AttributeGroup;
910
use PhpParser\Node\Expr\ArrowFunction;
@@ -137,6 +138,11 @@ public function refactor(Node $node): ?Node
137138
throw new InvalidConfigurationException(sprintf('The "%s" rule requires configuration.', self::class));
138139
}
139140

141+
// annotations converted to attributes only come from a docblock; skip nodes without one
142+
if (!$node->getDocComment() instanceof Doc) {
143+
return null;
144+
}
145+
140146
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
141147
if (! $phpDocInfo instanceof PhpDocInfo) {
142148
return null;

0 commit comments

Comments
 (0)