*/ final class ApiAndInternalAnnotationCheck implements Rule { public function getNodeType(): string { return InClassNode::class; } public function processNode(Node $node, Scope $scope): array { $reflection = $scope->getClassReflection(); if (! $reflection) { return []; } if ($reflection->isAnonymous()) { return []; } if (str_starts_with($reflection->getName(), 'CuyZ\Valinor\Tests')) { return []; } if (str_starts_with($reflection->getName(), 'CuyZ\Valinor\QA')) { return []; } if (! preg_match('/@(api|internal)\s+/', $reflection->getResolvedPhpDoc()?->getPhpDocString() ?? '')) { return [ RuleErrorBuilder::message( 'Missing annotation `@api` or `@internal`.' )->build(), ]; } return []; } }