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