1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Analyser;
4:
5: use PhpParser\Node;
6: use PhpParser\Node\Expr;
7: use PhpParser\Node\Name;
8: use PhpParser\Node\Param;
9: use PHPStan\Reflection\ClassConstantReflection;
10: use PHPStan\Reflection\ClassMemberAccessAnswerer;
11: use PHPStan\Reflection\ClassReflection;
12: use PHPStan\Reflection\ExtendedMethodReflection;
13: use PHPStan\Reflection\ExtendedPropertyReflection;
14: use PHPStan\Reflection\FunctionReflection;
15: use PHPStan\Reflection\MethodReflection;
16: use PHPStan\Reflection\NamespaceAnswerer;
17: use PHPStan\Reflection\ParameterReflection;
18: use PHPStan\Reflection\ParametersAcceptor;
19: use PHPStan\Reflection\Php\PhpFunctionFromParserNodeReflection;
20: use PHPStan\TrinaryLogic;
21: use PHPStan\Type\Type;
22: use PHPStan\Type\TypeWithClassName;
23:
24: /** @api */
25: interface Scope extends ClassMemberAccessAnswerer, NamespaceAnswerer
26: {
27:
28: public const SUPERGLOBAL_VARIABLES = [
29: 'GLOBALS',
30: '_SERVER',
31: '_GET',
32: '_POST',
33: '_FILES',
34: '_COOKIE',
35: '_SESSION',
36: '_REQUEST',
37: '_ENV',
38: ];
39:
40: public function getFile(): string;
41:
42: public function getFileDescription(): string;
43:
44: public function isDeclareStrictTypes(): bool;
45:
46: /**
47: * @phpstan-assert-if-true !null $this->getTraitReflection()
48: */
49: public function isInTrait(): bool;
50:
51: public function getTraitReflection(): ?ClassReflection;
52:
53: public function getFunction(): ?PhpFunctionFromParserNodeReflection;
54:
55: public function getFunctionName(): ?string;
56:
57: public function getParentScope(): ?self;
58:
59: public function hasVariableType(string $variableName): TrinaryLogic;
60:
61: public function getVariableType(string $variableName): Type;
62:
63: public function canAnyVariableExist(): bool;
64:
65: /**
66: * @return array<int, string>
67: */
68: public function getDefinedVariables(): array;
69:
70: /**
71: * @return array<int, string>
72: */
73: public function getMaybeDefinedVariables(): array;
74:
75: public function hasConstant(Name $name): bool;
76:
77: public function getPropertyReflection(Type $typeWithProperty, string $propertyName): ?ExtendedPropertyReflection;
78:
79: public function getMethodReflection(Type $typeWithMethod, string $methodName): ?ExtendedMethodReflection;
80:
81: public function getConstantReflection(Type $typeWithConstant, string $constantName): ?ClassConstantReflection;
82:
83: public function getIterableKeyType(Type $iteratee): Type;
84:
85: public function getIterableValueType(Type $iteratee): Type;
86:
87: public function isInAnonymousFunction(): bool;
88:
89: public function getAnonymousFunctionReflection(): ?ParametersAcceptor;
90:
91: public function getAnonymousFunctionReturnType(): ?Type;
92:
93: public function getType(Expr $node): Type;
94:
95: public function getNativeType(Expr $expr): Type;
96:
97: public function getKeepVoidType(Expr $node): Type;
98:
99: public function resolveName(Name $name): string;
100:
101: public function resolveTypeByName(Name $name): TypeWithClassName;
102:
103: /**
104: * @param mixed $value
105: */
106: public function getTypeFromValue($value): Type;
107:
108: public function hasExpressionType(Expr $node): TrinaryLogic;
109:
110: public function isInClassExists(string $className): bool;
111:
112: public function isInFunctionExists(string $functionName): bool;
113:
114: public function isInClosureBind(): bool;
115:
116: /** @return list<FunctionReflection|MethodReflection> */
117: public function getFunctionCallStack(): array;
118:
119: /** @return list<array{FunctionReflection|MethodReflection, ParameterReflection|null}> */
120: public function getFunctionCallStackWithParameters(): array;
121:
122: public function isParameterValueNullable(Param $parameter): bool;
123:
124: /**
125: * @param Node\Name|Node\Identifier|Node\ComplexType|null $type
126: */
127: public function getFunctionType($type, bool $isNullable, bool $isVariadic): Type;
128:
129: public function isInExpressionAssign(Expr $expr): bool;
130:
131: public function isUndefinedExpressionAllowed(Expr $expr): bool;
132:
133: public function filterByTruthyValue(Expr $expr): self;
134:
135: public function filterByFalseyValue(Expr $expr): self;
136:
137: public function isInFirstLevelStatement(): bool;
138:
139: }
140: