<?php

declare(strict_types=1);

namespace App\Framework\Quality\PHPStan\Rules;

use PhpParser\Node;
use PhpParser\Node\Stmt\Return_;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;

/**
 * @implements Rule<Return_>
 */
final class TestRule implements Rule
{
    public function getNodeType(): string
    {
        return Return_::class;
    }

    public function processNode(Node $node, Scope $scope): array
    {
        if (! $node instanceof Return_) {
            return [];
        }

        // This will trigger on every return statement - just for testing
        if ($scope->getClassReflection()?->getName() === 'App\\Application\\Analytics\\Service\\AnalyticsReportService') {
            return [
                RuleErrorBuilder::message('TEST RULE: Found return statement in AnalyticsReportService')->build(),
            ];
        }

        return [];
    }
}
