1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Type;
4:
5: use PhpParser\Node\Expr\MethodCall;
6: use PHPStan\Analyser\Scope;
7: use PHPStan\Broker\BrokerFactory;
8: use PHPStan\DependencyInjection\ExtensionInterface;
9: use PHPStan\Reflection\MethodReflection;
10:
11: /**
12: * This is the interface dynamic return type extensions implement for non-static methods.
13: *
14: * To register it in the configuration file use the `phpstan.broker.dynamicMethodReturnTypeExtension` service tag:
15: *
16: * ```
17: * services:
18: * -
19: * class: App\PHPStan\MyExtension
20: * tags:
21: * - phpstan.broker.dynamicMethodReturnTypeExtension
22: * ```
23: *
24: * Learn more: https://phpstan.org/developing-extensions/dynamic-return-type-extensions
25: *
26: * @api
27: */
28: #[ExtensionInterface(tag: BrokerFactory::DYNAMIC_METHOD_RETURN_TYPE_EXTENSION_TAG)]
29: interface DynamicMethodReturnTypeExtension
30: {
31:
32: /** @return class-string */
33: public function getClass(): string;
34:
35: public function isMethodSupported(MethodReflection $methodReflection): bool;
36:
37: public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type;
38:
39: }
40: