Skip to content
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

Option for less strict extension files dependency graph #5296

Closed
janedbal opened this issue Jul 13, 2021 · 1 comment · Fixed by phpstan/phpstan-src#595
Closed

Option for less strict extension files dependency graph #5296

janedbal opened this issue Jul 13, 2021 · 1 comment · Fixed by phpstan/phpstan-src#595

Comments

@janedbal
Copy link
Contributor

Feature request

We are using a lot of custom rules supporting internal company rules (naming unifications etc.). Such rules reference some "core" classes from app codebase. That is basically preventing to reuse cache between master and feature branches because when any file is changed, it is very like is it (transitively) a dependency of the class referenced in some naming rule. Example rule we use:

<?php declare(strict_types = 1);

/**
 * @implements Rule<Class_>
 */
class ExceptionNamingRule implements Rule
{

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

    /**
     * @param Class_ $node
     * @return string[] errors
     */
    public function processNode(Node $node, Scope $scope): array
    {
        $nodeName = $node->name;

        if (!is_a($node->extends->toString(), RuntimeException::class, true)) { // ref to app class
            return [];
        }

        $className = $nodeName->toString();
        $fullClassName = $node->namespacedName->toString();
        $parts = $node->namespacedName->parts;

        if (!Strings::endsWith($className, 'Exception')) {
            return ["$fullClassName should end with Exception suffix"];
        }

        return [];
    }

}

It would be very helpful to have some option so that only changes in the rule itself would invalidate the cache, not the whole dependency graph.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants