Replies: 1 comment 2 replies
-
Hello, public function getNodeType(): string
{
return Class_::class;
} And this tells PHPStan what /**
* @implements Rule<Node\Stmt\Class_>
*/
class MyCustomRule implements Rule The interface: /**
* @phpstan-template TNodeType of \PhpParser\Node
*/
interface Rule
{
/**
* @phpstan-return class-string<TNodeType>
* @return string
*/
public function getNodeType(): string;
/**
* @phpstan-param TNodeType $node
* @param \PhpParser\Node $node
* @param \PHPStan\Analyser\Scope $scope
* @return (string|RuleError)[] errors
*/
public function processNode(Node $node, Scope $scope): array;
} It also means that you don't have to have any PHPDoc above The synchronization between |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm creating a set of custom rules for PrestaShop on the repository phpstan-prestashop.
I'd like to help completing the documentation about custom rules and extensions.
Before submitting a PR to expand the doc I need to be sure what I understood about the topic is correct 😁 , can you confirm that
and
are equivalent? they tell phpstan "please only call this custom rules on Node whose type is ... is that right?
Beta Was this translation helpful? Give feedback.
All reactions