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: use PHPStan\DependencyInjection\ExtensionInterface;
10:
11: /**
12: * This is the interface custom rules implement. To register it in the configuration file
13: * use the `phpstan.rules.rule` service tag:
14: *
15: * ```
16: * services:
17: * -
18: * class: App\MyRule
19: * tags:
20: * - phpstan.rules.rule
21: * ```
22: *
23: * Learn more: https://phpstan.org/developing-extensions/rules
24: *
25: * @api
26: * @template TNodeType of Node
27: */
28: #[ExtensionInterface(tag: LazyRegistry::RULE_TAG)]
29: interface Rule
30: {
31:
32: /**
33: * @return class-string<TNodeType>
34: */
35: public function getNodeType(): string;
36:
37: /**
38: * @param TNodeType $node
39: * @return list<IdentifierRuleError>
40: */
41: public function processNode(Node $node, Scope&NodeCallbackInvoker&CollectedDataEmitter $scope): array;
42:
43: }
44: