1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Collectors;
4:
5: use PhpParser\Node;
6: use PHPStan\Analyser\DependencyTracker;
7: use PHPStan\Analyser\Scope;
8: use PHPStan\DependencyInjection\ExtensionInterface;
9:
10: /**
11: * This is the interface custom collectors implement. To register it in the configuration file
12: * use the `phpstan.collector` service tag:
13: *
14: * ```
15: * services:
16: * -
17: * class: App\MyCollector
18: * tags:
19: * - phpstan.collector
20: * ```
21: *
22: * Learn more: https://phpstan.org/developing-extensions/collectors
23: *
24: * @api
25: * @template-covariant TNodeType of Node
26: * @template-covariant TValue
27: */
28: #[ExtensionInterface(tag: RegistryFactory::COLLECTOR_TAG)]
29: interface Collector
30: {
31:
32: /**
33: * @return class-string<TNodeType>
34: */
35: public function getNodeType(): string;
36:
37: /**
38: * @param TNodeType $node
39: * @return TValue|null Collected data
40: */
41: public function processNode(Node $node, Scope&DependencyTracker $scope);
42:
43: }
44: