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