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