1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Reflection;
4:
5: use PHPStan\Broker\BrokerFactory;
6: use PHPStan\DependencyInjection\ExtensionInterface;
7: use PHPStan\Type\Type;
8:
9: /**
10: * This is the extension interface to implement if you want to described
11: * allowed subtypes - to limit which classes can implement a certain interface
12: * or extend a certain parent class.
13: *
14: * To register it in the configuration file use the `phpstan.broker.allowedSubTypesClassReflectionExtension` service tag:
15: *
16: * ```
17: * services:
18: * -
19: * class: App\PHPStan\MyExtension
20: * tags:
21: * - phpstan.broker.allowedSubTypesClassReflectionExtension
22: * ```
23: *
24: * Learn more: https://phpstan.org/developing-extensions/allowed-subtypes
25: *
26: * @api
27: */
28: #[ExtensionInterface(tag: BrokerFactory::ALLOWED_SUB_TYPES_CLASS_REFLECTION_EXTENSION_TAG)]
29: interface AllowedSubTypesClassReflectionExtension
30: {
31:
32: public function supports(ClassReflection $classReflection): bool;
33:
34: /**
35: * @return array<Type>
36: */
37: public function getAllowedSubTypes(ClassReflection $classReflection): array;
38:
39: }
40: