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