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