-
Notifications
You must be signed in to change notification settings - Fork 428
/
Type.php
165 lines (111 loc) · 4.77 KB
/
Type.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php declare(strict_types = 1);
namespace PHPStan\Type;
use PHPStan\Reflection\ClassMemberAccessAnswerer;
use PHPStan\Reflection\ConstantReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParametersAcceptor;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\Type\UnresolvedMethodPrototypeReflection;
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Generic\TemplateTypeMap;
use PHPStan\Type\Generic\TemplateTypeReference;
use PHPStan\Type\Generic\TemplateTypeVariance;
/** @api */
interface Type
{
/**
* @return string[]
*/
public function getReferencedClasses(): array;
public function accepts(Type $type, bool $strictTypes): TrinaryLogic;
public function isSuperTypeOf(Type $type): TrinaryLogic;
public function equals(Type $type): bool;
public function describe(VerbosityLevel $level): string;
public function canAccessProperties(): TrinaryLogic;
public function hasProperty(string $propertyName): TrinaryLogic;
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection;
public function getUnresolvedPropertyPrototype(string $propertyName, ClassMemberAccessAnswerer $scope): UnresolvedPropertyPrototypeReflection;
public function canCallMethods(): TrinaryLogic;
public function hasMethod(string $methodName): TrinaryLogic;
public function getMethod(string $methodName, ClassMemberAccessAnswerer $scope): MethodReflection;
public function getUnresolvedMethodPrototype(string $methodName, ClassMemberAccessAnswerer $scope): UnresolvedMethodPrototypeReflection;
public function canAccessConstants(): TrinaryLogic;
public function hasConstant(string $constantName): TrinaryLogic;
public function getConstant(string $constantName): ConstantReflection;
public function isIterable(): TrinaryLogic;
public function isIterableAtLeastOnce(): TrinaryLogic;
public function getIterableKeyType(): Type;
public function getIterableValueType(): Type;
public function isArray(): TrinaryLogic;
public function isOffsetAccessible(): TrinaryLogic;
public function hasOffsetValueType(Type $offsetType): TrinaryLogic;
public function getOffsetValueType(Type $offsetType): Type;
public function setOffsetValueType(?Type $offsetType, Type $valueType, bool $unionValues = true): Type;
public function unsetOffset(Type $offsetType): Type;
public function isCallable(): TrinaryLogic;
/**
* @return ParametersAcceptor[]
*/
public function getCallableParametersAcceptors(ClassMemberAccessAnswerer $scope): array;
public function isCloneable(): TrinaryLogic;
public function toBoolean(): BooleanType;
public function toNumber(): Type;
public function toInteger(): Type;
public function toFloat(): Type;
public function toString(): Type;
public function toArray(): Type;
public function isSmallerThan(Type $otherType): TrinaryLogic;
public function isSmallerThanOrEqual(Type $otherType): TrinaryLogic;
public function isString(): TrinaryLogic;
public function isNumericString(): TrinaryLogic;
public function isNonEmptyString(): TrinaryLogic;
public function isLiteralString(): TrinaryLogic;
public function getSmallerType(): Type;
public function getSmallerOrEqualType(): Type;
public function getGreaterType(): Type;
public function getGreaterOrEqualType(): Type;
/**
* Infers template types
*
* Infers the real Type of the TemplateTypes found in $this, based on
* the received Type.
*/
public function inferTemplateTypes(Type $receivedType): TemplateTypeMap;
/**
* Returns the template types referenced by this Type, recursively
*
* The return value is a list of TemplateTypeReferences, who contain the
* referenced template type as well as the variance position in which it was
* found.
*
* For example, calling this on array<Foo<T>,Bar> (with T a template type)
* will return one TemplateTypeReference for the type T.
*
* @param TemplateTypeVariance $positionVariance The variance position in
* which the receiver type was
* found.
*
* @return TemplateTypeReference[]
*/
public function getReferencedTemplateTypes(TemplateTypeVariance $positionVariance): array;
/**
* Traverses inner types
*
* Returns a new instance with all inner types mapped through $cb. Might
* return the same instance if inner types did not change.
*
* @param callable(Type):Type $cb
*/
public function traverse(callable $cb): Type;
/**
* Return the difference with another type, or null if it cannot be represented.
*
* @see TypeCombinator::remove()
*/
public function tryRemove(Type $typeToRemove): ?Type;
/**
* @param mixed[] $properties
*/
public static function __set_state(array $properties): self;
}