| 1: | <?php declare(strict_types = 1); |
| 2: | |
| 3: | namespace PHPStan\Rules\RestrictedUsage; |
| 4: | |
| 5: | use PHPStan\Analyser\Scope; |
| 6: | use PHPStan\Reflection\ExtendedMethodReflection; |
| 7: | |
| 8: | /** |
| 9: | * Extensions implementing this interface are called for each analysed method call. |
| 10: | * |
| 11: | * Extension can decide to create RestrictedUsage object |
| 12: | * with error message & error identifier to be reported for this method call. |
| 13: | * |
| 14: | * Typical usage is to report errors for methods marked as @-deprecated or @-internal. |
| 15: | * |
| 16: | * To register it in the configuration file use the following tag: |
| 17: | * |
| 18: | * ``` |
| 19: | * services: |
| 20: | * - |
| 21: | * class: App\PHPStan\MyExtension |
| 22: | * tags: |
| 23: | * - phpstan.restrictedMethodUsageExtension |
| 24: | * ``` |
| 25: | * |
| 26: | * @api |
| 27: | */ |
| 28: | interface RestrictedMethodUsageExtension |
| 29: | { |
| 30: | |
| 31: | public const METHOD_EXTENSION_TAG = 'phpstan.restrictedMethodUsageExtension'; |
| 32: | |
| 33: | public function isRestrictedMethodUsage( |
| 34: | ExtendedMethodReflection $methodReflection, |
| 35: | Scope $scope, |
| 36: | ): ?RestrictedUsage; |
| 37: | |
| 38: | } |
| 39: |