1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Type;
4:
5: use PhpParser\Node\Expr\StaticCall;
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 static 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: * An instantiation is asked about as a static call to __construct.
16: *
17: * The returned side effects replace the ones of the reflection for this call:
18: * whether it writes the object or class it is called on, which global state
19: * it forgets, whether its result is remembered, and whether it is pure. Like
20: * a functionMetadata entry, the call forgets global state only as far as it
21: * lists writes-global or a part of it. The arguments it writes are still the
22: * ones of the reflection: they are decided while the arguments are processed.
23: *
24: * To register it in the configuration file use the `phpstan.dynamicStaticMethodSideEffectsExtension` service tag:
25: *
26: * ```
27: * services:
28: * -
29: * class: App\PHPStan\MyExtension
30: * tags:
31: * - phpstan.dynamicStaticMethodSideEffectsExtension
32: * ```
33: *
34: * @api
35: */
36: #[ExtensionInterface(tag: 'phpstan.dynamicStaticMethodSideEffectsExtension')]
37: interface DynamicStaticMethodSideEffectsExtension
38: {
39:
40: public function getClass(): string;
41:
42: public function isStaticMethodSupported(ExtendedMethodReflection $methodReflection): bool;
43:
44: /** null keeps the side effects the method reflection describes */
45: public function getSideEffectsFromStaticMethodCall(ExtendedMethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): ?SideEffects;
46:
47: }
48: