| Methods |
public
static
|
fromInterval(?int $min, ?int $max, int $shift = 0): Type
|
#
|
protected
static
|
isDisjoint(?int $minA, ?int $maxA, ?int $minB, ?int $maxB, bool $touchingIsDisjoint = true): bool
|
#
|
public
static
|
createAllSmallerThan(int|float $value): Type
Return the range of integers smaller than the given value
Return the range of integers smaller than the given value
|
#
|
public
static
|
createAllSmallerThanOrEqualTo(int|float $value): Type
Return the range of integers smaller than or equal to the given value
Return the range of integers smaller than or equal to the given value
|
#
|
public
static
|
createAllGreaterThan(int|float $value): Type
Return the range of integers greater than the given value
Return the range of integers greater than the given value
|
#
|
public
static
|
createAllGreaterThanOrEqualTo(int|float $value): Type
Return the range of integers greater than or equal to the given value
Return the range of integers greater than or equal to the given value
|
#
|
public
|
getMin(): ?int
|
#
|
public
|
getMax(): ?int
|
#
|
public
|
describe(VerbosityLevel $level): string
|
#
|
public
|
shift(int $amount): Type
|
#
|
public
|
accepts(Type $type, bool $strictTypes): AcceptsResult
Unlike isSuperTypeOf(), accepts() takes into account PHP's implicit type coercion.
With $strictTypes = false, int is accepted by float, and Stringable objects are
accepted by string.
Unlike isSuperTypeOf(), accepts() takes into account PHP's implicit type coercion.
With $strictTypes = false, int is accepted by float, and Stringable objects are
accepted by string.
Implements
|
#
|
public
|
isSuperTypeOf(Type $type): IsSuperTypeOfResult
"Does every value of $type belong to $this type?" Preferable to instanceof checks because it correctly handles
union types, intersection types, and all other composite types.
"Does every value of $type belong to $this type?" Preferable to instanceof checks because it correctly handles
union types, intersection types, and all other composite types.
Implements
|
#
|
public
|
isSubTypeOf(Type $otherType): IsSuperTypeOfResult
Answers "is this compound type a subtype of $otherType?" from the compound type's perspective. Called by simple types when they encounter a CompoundType argument in their isSuperTypeOf() method.
The compound type decomposes itself and calls $otherType->isSuperTypeOf() for each component. For example, UnionType(string|int)::isSubTypeOf(MixedType) asks MixedType whether it is
a supertype of string and int separately, then combines with extremeIdentity (all must pass).
Answers "is this compound type a subtype of $otherType?" from the compound type's perspective. Called by simple types when they encounter a CompoundType argument in their isSuperTypeOf() method.
The compound type decomposes itself and calls $otherType->isSuperTypeOf() for each component. For example, UnionType(string|int)::isSubTypeOf(MixedType) asks MixedType whether it is
a supertype of string and int separately, then combines with extremeIdentity (all must pass).
Implements
|
#
|
public
|
isAcceptedBy(Type $acceptingType, bool $strictTypes): AcceptsResult
Answers "is this compound type accepted by $acceptingType?" from the compound type's perspective. Called by simple types when they encounter a CompoundType argument in their accepts() method.
The compound type decomposes itself and calls $acceptingType->accepts() for each component. For example, UnionType(string|int)::isAcceptedBy(StringType) asks StringType to accept
string and int separately, then combines results with extremeIdentity (all must pass).
Answers "is this compound type accepted by $acceptingType?" from the compound type's perspective. Called by simple types when they encounter a CompoundType argument in their accepts() method.
The compound type decomposes itself and calls $acceptingType->accepts() for each component. For example, UnionType(string|int)::isAcceptedBy(StringType) asks StringType to accept
string and int separately, then combines results with extremeIdentity (all must pass).
Implements
|
#
|
public
|
equals(Type $type): bool
|
#
|
public
|
generalize(GeneralizePrecision $precision): Type
Removes constant value information. E.g. 'foo' -> string, 1 -> int.
Used when types become too complex to track precisely (e.g. loop iterations).
Removes constant value information. E.g. 'foo' -> string, 1 -> int.
Used when types become too complex to track precisely (e.g. loop iterations).
Implements
|
#
|
public
|
isSmallerThan(Type $otherType, PhpVersion $phpVersion): TrinaryLogic
|
#
|
public
|
isSmallerThanOrEqual(Type $otherType, PhpVersion $phpVersion): TrinaryLogic
|
#
|
public
|
isGreaterThan(Type $otherType, PhpVersion $phpVersion): TrinaryLogic
Compares this compound type against $otherType using greater-than semantics. Used for comparison operators (>). Each compound type decomposes the comparison
across its members (e.g., IntegerRangeType checks whether all values in the range
are greater than the other type).
Compares this compound type against $otherType using greater-than semantics. Used for comparison operators (>). Each compound type decomposes the comparison
across its members (e.g., IntegerRangeType checks whether all values in the range
are greater than the other type).
Implements
|
#
|
public
|
isGreaterThanOrEqual(Type $otherType, PhpVersion $phpVersion): TrinaryLogic
Compares this compound type against $otherType using greater-than-or-equal semantics. Used for comparison operators (>=). Same decomposition strategy as isGreaterThan().
Compares this compound type against $otherType using greater-than-or-equal semantics. Used for comparison operators (>=). Same decomposition strategy as isGreaterThan().
Implements
|
#
|
public
|
getSmallerType(PhpVersion $phpVersion): Type
Type narrowing methods for comparison operators.
For example, for ConstantIntegerType(5), getSmallerType() returns int<min, 4>.
Type narrowing methods for comparison operators.
For example, for ConstantIntegerType(5), getSmallerType() returns int<min, 4>.
Implements
|
#
|
public
|
getSmallerOrEqualType(PhpVersion $phpVersion): Type
|
#
|
public
|
getGreaterType(PhpVersion $phpVersion): Type
|
#
|
public
|
getGreaterOrEqualType(PhpVersion $phpVersion): Type
|
#
|
public
|
toBoolean(): BooleanType
|
#
|
public
|
toAbsoluteNumber(): Type
|
#
|
public
|
toString(): Type
Models the (string) cast.
Models the (string) cast.
Overrides
Implements
|
#
|
public
|
tryUnion(Type $otherType): ?Type
Return the union with another type, but only if it can be expressed in a simpler way than using UnionType
Return the union with another type, but only if it can be expressed in a simpler way than using UnionType
|
#
|
public
|
tryIntersect(Type $otherType): ?Type
Return the intersection with another type, but only if it can be expressed in a simpler way than using
IntersectionType
Return the intersection with another type, but only if it can be expressed in a simpler way than using
IntersectionType
|
#
|
public
|
tryRemove(Type $typeToRemove): ?Type
Return the different with another type, or null if it cannot be represented.
Return the different with another type, or null if it cannot be represented.
Overrides
Implements
|
#
|
public
|
exponentiate(Type $exponent): Type
|
#
|
public
|
getFiniteTypes(): list<ConstantIntegerType>
Returns a list of finite values this type can take. Examples: - for bool: [true, false]
- for int<0, 3>: [0, 1, 2, 3]
- for enums: list of enum cases
- for scalars: the scalar itself For infinite types it returns an empty array.
Returns a list of finite values this type can take. Examples: - for bool: [true, false]
- for int<0, 3>: [0, 1, 2, 3]
- for enums: list of enum cases
- for scalars: the scalar itself For infinite types it returns an empty array.
Overrides
Implements
|
#
|
public
|
toPhpDocNode(): TypeNode
|
#
|
public
|
looseCompare(Type $type, PhpVersion $phpVersion): BooleanType
|
#
|