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