| Methods |
public
|
__construct(string $parameterName, Type $target, Type $if, Type $else, bool $negated)
|
#
|
public
|
getParameterName(): string
|
#
|
public
|
getTarget(): Type
|
#
|
public
|
getIf(): Type
|
#
|
public
|
getElse(): Type
|
#
|
public
|
isNegated(): bool
|
#
|
public
|
changeParameterName(string $parameterName): self
|
#
|
public
|
narrowTemplateType(TemplateType $templateType): self
Narrows the references to the template type the parameter is declared with along with
the parameter: @param T $param makes ($param is X ? A : B) narrow T to T & X in A
and to T ~ X in B, the way (T is X ? A : B) does (see NarrowedSubjectType). Only
sound when nothing but the parameter binds T.
Narrows the references to the template type the parameter is declared with along with
the parameter: @param T $param makes ($param is X ? A : B) narrow T to T & X in A
and to T ~ X in B, the way (T is X ? A : B) does (see NarrowedSubjectType). Only
sound when nothing but the parameter binds T.
|
#
|
public
static
|
resolveInType(Type $type, callable(string): ?Type $getSubjectType): Type
Replaces every ConditionalTypeForParameter inside $type with the ConditionalType on the
subject its parameter resolves to. $getSubjectType is called with the parameter name
including the leading $; returning null leaves that conditional unresolved. Shared by everything that resolves a declared conditional type against concrete
subjects: ResolvedFunctionVariant (@return, @param, @param-out,
@param-closure-this), TypeSpecifier (@phpstan-assert) and ConditionalTypeResolver
(@throws, @phpstan-self-out).
Replaces every ConditionalTypeForParameter inside $type with the ConditionalType on the
subject its parameter resolves to. $getSubjectType is called with the parameter name
including the leading $; returning null leaves that conditional unresolved. Shared by everything that resolves a declared conditional type against concrete
subjects: ResolvedFunctionVariant (@return, @param, @param-out,
@param-closure-this), TypeSpecifier (@phpstan-assert) and ConditionalTypeResolver
(@throws, @phpstan-self-out).
|
#
|
public
|
toConditional(Type $subject): Type
|
#
|
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
|
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
|
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
|
describe(VerbosityLevel $level): string
|
#
|
public
|
isResolvable(): bool
|
#
|
protected
|
getResult(): Type
|
#
|
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
|
toPhpDocNode(): TypeNode
|
#
|