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\DependencyInjection\ExtensionInterface;
8: use PHPStan\Reflection\ExtendedMethodReflection;
9: use PHPStan\Reflection\SideEffects;
10:
11: /**
12: * This is the interface dynamic side effects extensions implement for methods.
13: * They describe the side effects of one call, without the effects of the
14: * callables passed to the parameters flagged with @pure-unless-callable-is-impure.
15: *
16: * The returned side effects replace the ones of the reflection for this call:
17: * whether it writes the object or class it is called on, which global state
18: * it forgets, whether its result is remembered, and whether it is pure. Like
19: * a functionMetadata entry, the call forgets global state only as far as it
20: * lists writes-global or a part of it. The arguments it writes are still the
21: * ones of the reflection: they are decided while the arguments are processed.
22: *
23: * To register it in the configuration file use the `phpstan.dynamicMethodSideEffectsExtension` service tag:
24: *
25: * ```
26: * services:
27: * -
28: * class: App\PHPStan\MyExtension
29: * tags:
30: * - phpstan.dynamicMethodSideEffectsExtension
31: * ```
32: *
33: * @api
34: */
35: #[ExtensionInterface(tag: 'phpstan.dynamicMethodSideEffectsExtension')]
36: interface DynamicMethodSideEffectsExtension
37: {
38:
39: public function getClass(): string;
40:
41: public function isMethodSupported(ExtendedMethodReflection $methodReflection): bool;
42:
43: /** null keeps the side effects the method reflection describes */
44: public function getSideEffectsFromMethodCall(ExtendedMethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?SideEffects;
45:
46: }
47: