| Methods |
public
|
__construct(Type $type)
|
#
|
public
|
getReferencedClasses(): array
Returns all class names referenced anywhere in this type, recursively
(including generic arguments, callable signatures, etc.).
Returns all class names referenced anywhere in this type, recursively
(including generic arguments, callable signatures, etc.).
Implements
|
#
|
public
|
getGenericType(): Type
|
#
|
public
|
toObjectTypeForInstanceofCheck(): ClassNameToObjectTypeResult
Projects a class-name-or-object Type (the right-hand side of
$x instanceof <expr>) to the ObjectType it should be compared
against. Constant class strings collapse to their ObjectType
exactly; everything kept symbolically (object class names,
class-string<X>) carries an uncertainty flag so the caller can
fall back to BooleanType instead of a definite yes/no.
Projects a class-name-or-object Type (the right-hand side of
$x instanceof <expr>) to the ObjectType it should be compared
against. Constant class strings collapse to their ObjectType
exactly; everything kept symbolically (object class names,
class-string<X>) carries an uncertainty flag so the caller can
fall back to BooleanType instead of a definite yes/no.
Implements
|
#
|
public
|
toObjectTypeForIsACheck(Type $objectOrClassType, bool $allowString, bool $allowSameClass): ClassNameToObjectTypeResult
Projects a class-name-or-object Type (the second argument of
is_a($x, $class, $allow_string)) to the ObjectType to narrow
$x against. When $allowString is true, the is_a() result also
keeps the original class-string accepted alongside the object.
$allowSameClass controls whether matching the input's own class
collapses to NeverType for final classes (the call site's
"always-true" suppression).
Projects a class-name-or-object Type (the second argument of
is_a($x, $class, $allow_string)) to the ObjectType to narrow
$x against. When $allowString is true, the is_a() result also
keeps the original class-string accepted alongside the object.
$allowSameClass controls whether matching the input's own class
collapses to NeverType for final classes (the call site's
"always-true" suppression).
Implements
|
#
|
public
|
getClassStringObjectType(): Type
Returns the object type for a class-string or literal class name string.
For non-class-string types, returns ErrorType.
Returns the object type for a class-string or literal class name string.
For non-class-string types, returns ErrorType.
Overrides
|
#
|
public
|
getObjectTypeOrClassStringObjectType(): Type
Like getClassStringObjectType(), but also returns object types as-is.
Used for $classOrObject::method() where the left side can be either.
Like getClassStringObjectType(), but also returns object types as-is.
Used for $classOrObject::method() where the left side can be either.
Overrides
|
#
|
public
|
describe(VerbosityLevel $level): string
|
#
|
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.
Overrides
|
#
|
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.
Overrides
|
#
|
public
|
traverse(callable $cb): Type
Returns a new instance with all inner types mapped through $cb.
Returns the same instance if inner types did not change. Not used directly — use TypeTraverser::map() instead.
Returns a new instance with all inner types mapped through $cb.
Returns the same instance if inner types did not change. Not used directly — use TypeTraverser::map() instead.
Implements
|
#
|
public
|
traverseSimultaneously(Type $right, callable $cb): Type
Like traverse(), but walks two types simultaneously. Not used directly — use SimultaneousTypeTraverser::map() instead.
Like traverse(), but walks two types simultaneously. Not used directly — use SimultaneousTypeTraverser::map() instead.
Implements
|
#
|
public
|
inferTemplateTypes(Type $receivedType): TemplateTypeMap
Infers the real types of TemplateTypes found in $this, based on
the received Type. E.g. if $this is array<T> and $receivedType
is array, infers T = int.
Infers the real types of TemplateTypes found in $this, based on
the received Type. E.g. if $this is array<T> and $receivedType
is array, infers T = int.
Implements
|
#
|
public
|
getReferencedTemplateTypes(TemplateTypeVariance $positionVariance): array
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.
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.
Parameters
| $positionVariance |
The variance position in
which the receiver type was
found.
|
Implements
|
#
|
public
|
equals(Type $type): bool
|
#
|
public
|
toPhpDocNode(): TypeNode
|
#
|
public
|
tryRemove(Type $typeToRemove): ?Type
|
#
|
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.
Overrides
|
#
|