1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Rules;
4:
5: use PhpParser\Node;
6: use PHPStan\Analyser\CollectedDataEmitter;
7: use PHPStan\Analyser\NodeCallbackInvoker;
8: use PHPStan\Analyser\Scope;
9:
10: /**
11: * This is the interface custom rules implement. To register it in the configuration file
12: * use the `phpstan.rules.rule` service tag:
13: *
14: * ```
15: * services:
16: * -
17: * class: App\MyRule
18: * tags:
19: * - phpstan.rules.rule
20: * ```
21: *
22: * Learn more: https://phpstan.org/developing-extensions/rules
23: *
24: * @api
25: * @template TNodeType of Node
26: */
27: interface Rule
28: {
29:
30: /**
31: * @return class-string<TNodeType>
32: */
33: public function getNodeType(): string;
34:
35: /**
36: * @param TNodeType $node
37: * @return list<IdentifierRuleError>
38: */
39: public function processNode(Node $node, Scope&NodeCallbackInvoker&CollectedDataEmitter $scope): array;
40:
41: }
42: