1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Rules\RestrictedUsage;
4:
5: use PHPStan\Analyser\Scope;
6: use PHPStan\DependencyInjection\ExtensionInterface;
7: use PHPStan\Reflection\ClassReflection;
8: use PHPStan\Rules\ClassNameUsageLocation;
9:
10: /**
11: * Extensions implementing this interface are called for each analysed class name usage.
12: *
13: * Extension can decide to create RestrictedUsage object
14: * with error message & error identifier to be reported for this method call.
15: *
16: * Typical usage is to report errors for class names marked as @-deprecated or @-internal.
17: *
18: * Extension can take advantage of the usage location information in the ClassNameUsageLocation object.
19: *
20: * To register the extension in the configuration file use the following tag:
21: *
22: * ```
23: * services:
24: * -
25: * class: App\PHPStan\MyExtension
26: * tags:
27: * - phpstan.restrictedClassNameUsageExtension
28: * ```
29: *
30: * @api
31: */
32: #[ExtensionInterface(tag: self::CLASS_NAME_EXTENSION_TAG)]
33: interface RestrictedClassNameUsageExtension
34: {
35:
36: public const CLASS_NAME_EXTENSION_TAG = 'phpstan.restrictedClassNameUsageExtension';
37:
38: public function isRestrictedClassNameUsage(
39: ClassReflection $classReflection,
40: Scope $scope,
41: ClassNameUsageLocation $location,
42: ): ?RestrictedUsage;
43:
44: }
45: