final |
|---|
Represents the variance of a template type parameter.
Variance describes how subtyping of a generic type relates to subtyping of its
type arguments. For a class Box<T>:
Box<Cat> is NOT a subtype of Box<Animal>, even though
Cat extends Animal. The type argument must match exactly. Declared with @template T.Box<Cat> IS a subtype of Box<Animal>. Safe when T only appears
in "output" positions (return types). Declared with @template-covariant T.Box<Animal> IS a subtype of Box<Cat>. Safe when T only
appears in "input" positions (parameter types). Declared with @template-contravariant T.static return type in template context.Variance composition follows standard rules — e.g. covariant composed with contravariant yields contravariant. This is used when template types appear inside nested generic types.
| Methods | ||
|---|---|---|
public
static
|
createInvariant(): self
|
# |
public
static
|
createCovariant(): self
|
# |
public
static
|
createContravariant(): self
|
# |
public
static
|
createStatic(): self
|
# |
public
static
|
createBivariant(): self
|
# |
public
|
invariant(): bool
|
# |
public
|
covariant(): bool
|
# |
public
|
contravariant(): bool
|
# |
public
|
static(): bool
|
# |
public
|
bivariant(): bool
|
# |
public
|
compose(self $other): self
|
# |
public
|
isValidVariance(TemplateType $templateType, Type $a, Type $b, bool $strict = false): IsSuperTypeOfResult
|
# |
public
|
equals(self $other): bool
|
# |
public
|
validPosition(self $other): bool
|
# |
public
|
describe(): string
|
# |
public
|
toPhpDocNodeVariance(): GenericTypeNode::VARIANCE_*
|
# |