-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#595Labels
Description
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.