Skip to content

Not for @phpstan-ignore #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
petski opened this issue Sep 18, 2024 · 1 comment
Open

Not for @phpstan-ignore #1

petski opened this issue Sep 18, 2024 · 1 comment

Comments

@petski
Copy link

petski commented Sep 18, 2024

As of phpstan 1.11, we have @phpstan-ignore. Was supporting this annotation out of scope for this project, or is this a missing feature. Thanks in advance!

p.s. perhaps also wise to follow phpstan/phpstan#11340

@petski
Copy link
Author

petski commented Sep 18, 2024

If it is your intention to implement this project to support @phpstan-ignore, this would be the fastest approach:

public function getNodeType(): string
{
    return FileNode::class;
}

public function processNode(Node $node, Scope $scope): array
{
    /** @var array<int, non-empty-list<string>|null> $linesToIgnore */
    $linesToIgnore = $node->getAttribute('linesToIgnore');

    $errors = [];

    // identifiersToIgnore is null in case no specific identifiers are set, and a (non-empty) array in case specific identifiers are set
    foreach ($linesToIgnore as $lineToIgnore => $identifiersToIgnore) {
        $errors[] = RuleErrorBuilder::message('PHPStan ignored line')
          ->tip('Just fix the issue instead of ignoring it.')
          ->nonIgnorable()
          ->line($lineToIgnore)
          ->identifier('phpstan.ignore')
          ->build()
        ;
    }

    return $errors;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant