| Methods |
public
|
__construct()
|
#
|
public
|
getConstantStrings(): array
|
#
|
public
|
getConstantScalarTypes(): array
|
#
|
public
|
getConstantScalarValues(): array
|
#
|
public
|
describe(VerbosityLevel $level): string
|
#
|
public
|
toNumber(): Type
Models numeric coercion for arithmetic operators.
Models numeric coercion for arithmetic operators.
Overridden by
Implements
|
#
|
public
|
toBitwiseNotType(): Type
Models the bitwise-not (~$x) operator. Returns ErrorType for types where ~ is undefined.
Models the bitwise-not (~$x) operator. Returns ErrorType for types where ~ is undefined.
Overridden by
Implements
|
#
|
public
|
toAbsoluteNumber(): Type
|
#
|
public
|
toString(): Type
Models the (string) cast.
Models the (string) cast.
Overridden by
Implements
|
#
|
public
|
toInteger(): Type
|
#
|
public
|
toFloat(): Type
|
#
|
public
|
toArray(): Type
|
#
|
public
|
toArrayKey(): Type
Models PHP's implicit array key coercion: floats truncated to int,
booleans become 0/1, null becomes '', numeric strings become int.
Models PHP's implicit array key coercion: floats truncated to int,
booleans become 0/1, null becomes '', numeric strings become int.
Overridden by
Implements
|
#
|
public
|
toCoercedArgumentType(bool $strictTypes): Type
Returns how this type might change when passed to a typed parameter
or assigned to a typed property.
Returns how this type might change when passed to a typed parameter
or assigned to a typed property.
With $strictTypes = true: int widens to int|float (since int is accepted
by float parameters in strict mode).
With $strictTypes = false: additional coercions apply, e.g. Stringable
objects are accepted by string parameters.
Used internally to determine what types a value might be coerced to
when checking parameter acceptance.
Overridden by
Implements
|
#
|
public
|
isOffsetAccessLegal(): TrinaryLogic
Whether accessing a non-existent offset is safe (won't cause errors).
Unlike isOffsetAccessible() which checks if offset access is supported at all.
Whether accessing a non-existent offset is safe (won't cause errors).
Unlike isOffsetAccessible() which checks if offset access is supported at all.
Implements
|
#
|
public
|
getKindMask(): int
The kinds of values this type may hold, as TypeKind bits: a bit can be
set for a kind the type holds no value of, never the other way round.
Unions OR the masks of their members, intersections AND them.
The kinds of values this type may hold, as TypeKind bits: a bit can be
set for a kind the type holds no value of, never the other way round.
Unions OR the masks of their members, intersections AND them.
Overridden by
Implements
|
#
|
public
|
isNull(): TrinaryLogic
|
#
|
public
|
isTrue(): TrinaryLogic
|
#
|
public
|
isFalse(): TrinaryLogic
|
#
|
public
|
isBoolean(): TrinaryLogic
|
#
|
public
|
isScalar(): TrinaryLogic
|
#
|
public
|
looseCompare(Type $type, PhpVersion $phpVersion): BooleanType
|
#
|
public
|
tryRemove(Type $typeToRemove): ?Type
|
#
|
public
|
getFiniteTypes(): array
Returns a list of finite values this type can take.
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.
Implements
|
#
|
public
|
arithmeticPower(Type $exponent, PhpVersion $phpVersion): Type
|
#
|
public
|
toPhpDocNode(): TypeNode
|
#
|
public
|
toNativePhpTypeNode(NativeTypePosition $position)
The native PHP type declaration for this type at the given position,
widened to what the position allows, e.g. non-empty-string to string.
Returns null when the type cannot be declared natively there.
The native PHP type declaration for this type at the given position,
widened to what the position allows, e.g. non-empty-string to string.
Returns null when the type cannot be declared natively there.
Overridden by
Implements
|
#
|
public
|
toTrinaryLogic(): TrinaryLogic
|
#
|
public
|
hasTemplateOrLateResolvableType(): bool
Performance optimization to skip template resolution when no templates are present.
Performance optimization to skip template resolution when no templates are present.
Implements
|
#
|
public
|
hasUnresolvedTemplateArgumentType(): bool
Whether an UnresolvedTemplateArgumentType occurs anywhere in the type:
a template argument that is still being inferred.
Whether an UnresolvedTemplateArgumentType occurs anywhere in the type:
a template argument that is still being inferred.
Implements
|
#
|
public
|
toValueSet(): ValueSet
The values this type holds, by the kinds of values PHP's operators tell apart.
A union of types is the union of their sets, an intersection their intersection.
The values this type holds, by the kinds of values PHP's operators tell apart.
A union of types is the union of their sets, an intersection their intersection.
Overridden by
Implements
|
#
|
public
|
tryUnion(Type $otherType): ?Type
The union with the other type as this type alone, when this type absorbs
it by more than being its supertype, such as mixed~int|1 being
mixed~(int<min, 0>|int<2, max>). Null when it does not; TypeCombinator::union()
asks the other type the same.
The union with the other type as this type alone, when this type absorbs
it by more than being its supertype, such as mixed~int|1 being
mixed~(int<min, 0>|int<2, max>). Null when it does not; TypeCombinator::union()
asks the other type the same.
Implements
|
#
|
public
|
tryIntersect(Type $otherType): ?Type
The intersection with the other type as one type, when this type knows it
better than as the subtype of the two, such as Foo & object~Bar being
Foo~Bar. Null when it does not; TypeCombinator::intersect() asks the
other type the same, and asks both before it drops supertypes. A type that
compares the two to find out may return the one the other holds instead.
The intersection with the other type as one type, when this type knows it
better than as the subtype of the two, such as Foo & object~Bar being
Foo~Bar. Null when it does not; TypeCombinator::intersect() asks the
other type the same, and asks both before it drops supertypes. A type that
compares the two to find out may return the one the other holds instead.
Implements
|
#
|