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