final |
|---|
Maps template type parameter names to their resolved types.
This is the core data structure for PHPStan's generics support. When a class declares
@template T, @template U of object, etc., the TemplateTypeMap tracks what concrete
types T and U resolve to in a particular context.
Two kinds of type bindings are tracked:
@template T of Countable, if T is inferred as array, types maps T → array.TemplateTypeMap supports set operations (union, intersect, benevolentUnion) that combine maps from different code paths, and resolveToBounds() which replaces unresolved template types with their declared bounds.
Common usage: ParametersAcceptor::getTemplateTypeMap() returns the template declarations, and ParametersAcceptor::getResolvedTemplateTypeMap() returns inferred concrete types. Type::inferTemplateTypes() produces a TemplateTypeMap from a concrete type.
| Methods | ||
|---|---|---|
public
|
__construct(array<string, Type> $types, array<string, Type> $lowerBoundTypes = [])
|
# |
public
|
convertToLowerBoundTypes(): self
|
# |
public
static
|
createEmpty(): self
|
# |
public
|
isEmpty(): bool
|
# |
public
|
count(): int
|
# |
public
|
getTypes(): array<string, Type>
|
# |
public
|
hasType(string $name): bool
|
# |
public
|
getType(string $name): ?Type
|
# |
public
|
unsetType(string $name): self
|
# |
public
|
union(self $other): self
|
# |
public
|
benevolentUnion(self $other): self
|
# |
public
|
intersect(self $other): self
|
# |
public
|
map(callable(string, Type): Type $cb): self
|
# |
public
|
resolveToBounds(): self
|
# |