class EagerLoadMapType implements CompoundType, LateResolvableType

The expected type of a relation-keyed map, built per key from the map a call passes.

The method template takes the whole argument, as in eager-loads<TModel, TRelations> with @template TRelations of array, so each constant key's callback expects that key's own relation or builder. Upstream's stubs union the keys instead, which accepts a callback written for another key's relation. Integer keys, keys that name no model and maps without constant keys keep Laravel's value type. Optional keys stay optional, and a supplied callback's type never becomes part of the expected type.

Traits

LateResolvableTypeTrait

Methods

__construct(EagerLoadMapKind $kind, Type|null $model, Type $map, BuilderHelper $builderHelper)

Create an eager-load map type.

Type
getResult()

Build the expected map from the map's constant keys.

TemplateTypeMap
inferTemplateTypes(Type $receivedType)

Infer the map template from the whole argument, so each key keeps its own value.

bool
isResolvable()

Determine whether the type can be resolved, which waits for its template types.

array
getReferencedClasses()

Get the classes the type refers to.

array
getReferencedTemplateTypes(TemplateTypeVariance $positionVariance)

Get the template types the type refers to.

bool
equals(Type $type)

Determine whether the type equals another.

string
describe(VerbosityLevel $level)

Describe the type.

Type
traverse(callable $cb)

Map the inner types.

Type
traverseSimultaneously(Type $right, callable $cb)

Map the inner types together with another eager-load map type's.

TypeNode
toPhpDocNode()

Convert the type to a PHPDoc node.

Type
generalize(GeneralizePrecision $precision)

Generalize the inner types.

Details

at line 63
__construct(EagerLoadMapKind $kind, Type|null $model, Type $map, BuilderHelper $builderHelper)

Create an eager-load map type.

Parameters

EagerLoadMapKind $kind
Type|null $model
Type $map
BuilderHelper $builderHelper

at line 74
protected Type getResult()

Build the expected map from the map's constant keys.

Return Value

Type

at line 317
TemplateTypeMap inferTemplateTypes(Type $receivedType)

Infer the map template from the whole argument, so each key keeps its own value.

Parameters

Type $receivedType

Return Value

TemplateTypeMap

at line 325
bool isResolvable()

Determine whether the type can be resolved, which waits for its template types.

Return Value

bool

at line 336
array getReferencedClasses()

Get the classes the type refers to.

Return Value

array

at line 346
array getReferencedTemplateTypes(TemplateTypeVariance $positionVariance)

Get the template types the type refers to.

Parameters

TemplateTypeVariance $positionVariance

Return Value

array

at line 359
bool equals(Type $type)

Determine whether the type equals another.

Parameters

Type $type

Return Value

bool

at line 370
string describe(VerbosityLevel $level)

Describe the type.

Parameters

VerbosityLevel $level

Return Value

string

at line 382
Type traverse(callable $cb)

Map the inner types.

Parameters

callable $cb

Return Value

Type

at line 397
Type traverseSimultaneously(Type $right, callable $cb)

Map the inner types together with another eager-load map type's.

Parameters

Type $right
callable $cb

Return Value

Type

at line 416
TypeNode toPhpDocNode()

Convert the type to a PHPDoc node.

Return Value

TypeNode

at line 427
Type generalize(GeneralizePrecision $precision)

Generalize the inner types.

Parameters

GeneralizePrecision $precision

Return Value

Type