| 1: | <?php declare(strict_types = 1); | 
| 2: | |
| 3: | namespace PHPStan\Analyser; | 
| 4: | |
| 5: | use PhpParser\Node; | 
| 6: | |
| 7: | /** | 
| 8: | * The interface NodeCallbackInvoker can be typehinted in 2nd parameter of Rule::processNode(): | 
| 9: | * | 
| 10: | * ```php | 
| 11: | * public function processNode(Node $node, Scope&NodeCallbackInvoker $scope): array | 
| 12: | * ``` | 
| 13: | * | 
| 14: | * It can be used to invoke rules for virtual made-up nodes. | 
| 15: | * | 
| 16: | * For example: You're writing a rule for a method with declaration like: | 
| 17: | * | 
| 18: | * ```php | 
| 19: | * public static create(string $class, mixed ...$args) | 
| 20: | * ``` | 
| 21: | * | 
| 22: | * And you'd like to check `Factory::create(Foo::class, 1, 2, 3)` as if it were | 
| 23: | * `new Foo(1, 2, 3)`. | 
| 24: | * | 
| 25: | * You can call `$scope->invokeNodeCallback(new New_(new Name($className), $args))` | 
| 26: | * | 
| 27: | * And PHPStan will call all the registered rules for New_, checking as if the instantiation | 
| 28: | * is actually in the code. | 
| 29: | * | 
| 30: | * @api | 
| 31: | */ | 
| 32: | interface NodeCallbackInvoker | 
| 33: | { | 
| 34: | |
| 35: | public function invokeNodeCallback(Node $node): void; | 
| 36: | |
| 37: | } | 
| 38: |