Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rules/Php80/Rector/Class_/AnnotationToAttributeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Php80\Rector\Class_;

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

// annotations converted to attributes only come from a docblock; skip nodes without one
if (!$node->getDocComment() instanceof Doc) {
return null;
}

$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
if (! $phpDocInfo instanceof PhpDocInfo) {
return null;
Expand Down
Loading