class DataCreator

Creates data objects by filling, validating, and constructing them over one ConstructionState.

Fill normalizes and prepares the input and records each decision that depends on the raw input: selected union types, wire-key mappings, morph classes, automatic lazy and paginator sources, and deferred named factories. Validation and construction read those records instead of deciding again from normalized values. When a validation hook replaces a value, reconciliation prepares it again.

Beneath a property with an explicit cast, validated input is still normalized and prepared, but named factories and object construction wait until the cast declines the value.

Properties

protected CreationContext> $defaultContexts
protected CreationExtensions $emptyExtensions

The empty extensions each operation clones; it is never used directly.

Methods

__construct(Container $container, DataClassRepository $dataClasses, DataConfig $config, DataCollectableFactory $dataCollectables, DataInstantiator $instantiator, DataValidator $validator)

Create a data creator.

factory(string $class, CreationContext|null $creationContext = null)

Create a fresh construction factory for a data class.

create(string $class, CreationContext $context, mixed ...$payloads)

Create a data object through one fixed construction operation.

array
validate(string $class, CreationContext $context, array $payloads)

Validate a payload without casting or construction.

array
getValidationRules(string $class, CreationContext $context, array $payloads)

Get validation rules for a payload without running the Validator.

mixed
resolveAutoLazyProperty(string $propertyName, mixed $value, ConstructionState $state, AutoLazyReplayMode|null $replay, array|null $castInputs = null)

Resolve one deferred automatic lazy property.

collect(string $class, CreationContext $context, mixed $items, string|null $into = null)

Collect data objects through one root operation.

collectItems(string $class, CreationContext $context, mixed $items)

Create typed items through one internal collection operation.

deferCollectionItems(string $class, CreationContext $context, LazyCollection $source)

Create a deferred item collection with one shared operation memo.

createUnvalidatedNode(string $class, CreationContext $context, array $payloads, CreationExtensions $extensions)

Create one nested node without restarting root validation or authorization.

collectEager(string $class, CreationContext $context, mixed $source, array $values, string|null $into, bool $shouldValidate)

Collect an eager source through one Fill and validation graph.

array
createEagerCollectionItems(string $class, CreationContext $context, mixed $source, array $values, bool $shouldValidate)

Create every eager item through one Fill and validation graph.

void
loadMissingRelations(string $class, Collection $models)

Batch relations explicitly selected by data properties.

void
fillCollectionItems(string $class, array $values, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate)

Fill every eager root collection item into one construction state.

array
castCollectionItems(string $class, ConstructionState $state, CreationExtensions $extensions)

Cast and instantiate every eager root collection item.

BaseData|array
execute(string $class, CreationContext $context, array $payloads)

Run the fixed operation through its selected exit point.

BaseData|null
fillNode(string $class, array $payloads, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Normalize and fill one data node into the root construction state.

bool
fillGeneralNode(DataClass $dataClass, array $payloads, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Fill one post-factory value through the general construction path.

BaseData|null
tryCreateDirectArrayNode(DataClass $dataClass, array $payloads, CreationContext $context, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Create one fixed array node without entering the general Fill path.

BaseData|null
fillHookNode(string $class, mixed $payload, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Fill one node introduced or changed by a validation payload hook.

void
fillConstructorInputs(DataClass $dataClass, array $sources, ConstructionState $state)

Write the raw input of constructor parameters that have no public data property.

void
fillResolvedProperties(DataClass $dataClass, array $resolvedProperties, array $sources, array $payloads, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules, bool $fromValidationHook)

Write one resolved data node and recursively fill its declared children.

void
fillResolvedProperty(DataProperty $property, array $inputPath, mixed $value, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules, bool $fromValidationHook)

Write one resolved property and recursively fill its declared children.

void
applyPayloadHooks(string $class, array $hooks, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules, bool $reconcile = true, bool $collection = false)

Apply one root payload-hook stage and reconcile changed selections.

void
reconcileCollection(string $class, array $previousPayload, array $payload, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Reconcile changed eager root collection items.

void
reconcileNode(string $declaredClass, array $previousPayload, array $payload, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Reconcile one changed assembled data node without replaying prepare hooks.

void
rematchDeferredFactory(DataClass $dataClass, array $payload, ConstructionState $state)

Match the named factory again for a node beneath a cast whose input a validation hook replaced.

void
reconcileProperty(DataProperty $property, mixed $previousValue, mixed $value, string|int $wireKey, array $payload, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Reconcile one changed property selection.

void
reconcileDataIterable(DataProperty $property, NamedType $type, mixed $previousValue, mixed $value, array $inputPath, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Reconcile one changed typed data iterable.

castAndInstantiateNode(ConstructionState $state, CreationExtensions $extensions)

Cast and instantiate the node at the current construction path.

mixed
buildAutoLazy(DataProperty $property, mixed $value, ConstructionState $state, CreationExtensions $extensions, array $properties = [], array|null $castInputs = null)

Build one automatic lazy property around the ordinary cast path.

mixed
castProperty(DataProperty $property, mixed $value, ConstructionState $state, CreationExtensions $extensions, array $properties = [], array|null $castInputs = null)

Cast one supplied property value.

mixed
castDataIterable(DataProperty $property, NamedType $type, mixed $value, ConstructionState $state, CreationExtensions $extensions)

Cast every item in one declared data iterable.

mixed
castTypedIterable(DataProperty $property, NamedType $type, mixed $value, ConstructionState $state, CreationExtensions $extensions, array $casts, array $properties, array|null $castInputs)

Cast every item in one declared non-data iterable.

mixed
castIterableItem(DataProperty $property, Type $type, mixed $value, ConstructionState $state, CreationExtensions $extensions, array $casts, array $castInputs)

Cast one declared iterable item.

array
castInputs(ConstructionState $state, array $properties)

Build the declared property values a user cast receives for the current node.

bool
requiresCastInputs(DataProperty $property, CreationContext $context, CreationExtensions $extensions)

Determine if casting a property can reach a user cast that receives the declared values.

bool
hasCastableType(Type $type)

Determine if a type accepts a Castable class.

bool
isCastOwned(DataProperty $property, CreationContext $context, CreationExtensions $extensions)

Determine if casts own the construction of a data object or collection property.

array
resolveProperties(DataClass $dataClass, array $sources, CreationContext $context, bool $compilesRules)

Resolve every declared property against the normalized sources.

array
resolveProperty(array $sources, DataProperty $property, CreationContext $context, bool $compilesRules)

Resolve one property from the last source that supplies it, with mapped-key precedence inside each source.

mixed
resolveAutoLazySource(DataProperty $property, array $sources, array $payloads, CreationContext $context, bool $compilesRules)

Resolve the raw source aligned with one automatic lazy property.

array|null
matchPropertySource(array|Normalized $source, DataProperty $property, string|int $mappedKey, bool $compilesRules)

Match one property against one normalized source.

string|int
propertyInputKey(DataProperty $property, CreationContext $context)

Get the effective input key for one property.

array
prepareSourcesForPipeline(DataClass $dataClass, array $sources, CreationContext $context, bool $compilesRules)

Pass each normalized source through the class's prepareForPipeline() method.

array
prepareDataInput(DataClass $dataClass, array $sources, array $resolvedProperties, CreationContext $context, bool $compilesRules)

Build the prepare-data hook input from the values property resolution selects.

array
mergeArraySources(array $sources)

Merge the array sources, with later sources taking precedence.

array
mergeSources(DataClass $dataClass, array $sources, CreationContext $context, bool $compilesRules)

Merge the keys of every normalized source for unknown-field detection.

array
projectNormalizedSource(DataClass $dataClass, Normalized $source, CreationContext $context, bool $compilesRules)

Project a non-enumerable normalized source into declared wire keys.

array
mergeMissingValues(array $target, array $source)

Recursively fill only values absent from the earlier source.

array|null
matchNamedFactory(DataClass $dataClass, CreationContext $context, array $payloads)

Find the first compatible named object factory.

BaseData|array
resolveFactoryPayloads(DataClass $dataClass, CreationContext $context, array $payloads)

Create the object with a matching named factory, or list the payloads for ordinary creation.

array|null
matchNamedCollectionFactory(DataClass $dataClass, CreationContext $context, mixed $items, string|null $into)

Find the first compatible named collection factory.

mixed
invokeNamedFactory(DataClass $dataClass, DataMethod $method, DataMethodMatch $match)

Invoke one matched named factory without method-binding interception.

invokeNamedObjectFactory(DataClass $dataClass, DataMethod $method, DataMethodMatch $match)

Invoke one matched named object factory, which must return the requested object.

string
resolveMorphClass(DataClass $dataClass, array $resolvedProperties, bool $compilesRules)

Resolve the concrete class selected by an abstract property's discriminator.

mixed
propertyDefaultValue(DataClass $dataClass, DataProperty $property)

Materialize a property default only when morph selection requires it.

bool
requiresAutoLazyReplay(DataProperty $property, CreationContext $context, CreationExtensions $extensions)

Determine if an automatic lazy property needs deferred Fill replay.

bool
isAutoWhenLoaded(DataProperty $property)

Determine if a property uses model relation automatic lazy loading.

NamedType|null
selectType(DataProperty $property, mixed $value, ConstructionState $state)

Select and record the declared type that receives a union value.

void
retainPaginatorSource(DataProperty $property, NamedType $type, mixed $value, array $inputPath, ConstructionState $state)

Retain source metadata for one declared paginator property.

array|null
iterableValues(mixed $value)

Convert an eager iterable to its keyed values.

Details

at line 82
__construct(Container $container, DataClassRepository $dataClasses, DataConfig $config, DataCollectableFactory $dataCollectables, DataInstantiator $instantiator, DataValidator $validator)

Create a data creator.

Parameters

Container $container
DataClassRepository $dataClasses
DataConfig $config
DataCollectableFactory $dataCollectables
DataInstantiator $instantiator
DataValidator $validator

at line 103
CreationContextFactory factory(string $class, CreationContext|null $creationContext = null)

Create a fresh construction factory for a data class.

A given creation context supplies its options, but not its hooks, which belong to its own operation.

Parameters

string $class
CreationContext|null $creationContext

Return Value

CreationContextFactory

at line 136
BaseData create(string $class, CreationContext $context, mixed ...$payloads)

Create a data object through one fixed construction operation.

Parameters

string $class
CreationContext $context
mixed ...$payloads

Return Value

BaseData

at line 154
array validate(string $class, CreationContext $context, array $payloads)

Validate a payload without casting or construction.

Parameters

string $class
CreationContext $context
array $payloads

Return Value

array

at line 172
array getValidationRules(string $class, CreationContext $context, array $payloads)

Get validation rules for a payload without running the Validator.

Parameters

string $class
CreationContext $context
array $payloads

Return Value

array

at line 188
mixed resolveAutoLazyProperty(string $propertyName, mixed $value, ConstructionState $state, AutoLazyReplayMode|null $replay, array|null $castInputs = null)

internal  
 

Resolve one deferred automatic lazy property.

Parameters

string $propertyName
mixed $value
ConstructionState $state
AutoLazyReplayMode|null $replay
array|null $castInputs

Return Value

mixed

at line 232
array|DataCollection|PaginatedDataCollection|CursorPaginatedDataCollection|Enumerable|AbstractPaginator|Paginator|AbstractCursorPaginator|CursorPaginator|LazyCollection|Collection collect(string $class, CreationContext $context, mixed $items, string|null $into = null)

Collect data objects through one root operation.

Parameters

string $class
CreationContext $context
mixed $items

null collects an empty $into target

string|null $into

Return Value

array|DataCollection|PaginatedDataCollection|CursorPaginatedDataCollection|Enumerable|AbstractPaginator|Paginator|AbstractCursorPaginator|CursorPaginator|LazyCollection|Collection

at line 278
Enumerable collectItems(string $class, CreationContext $context, mixed $items)

internal  
 

Create typed items through one internal collection operation.

Parameters

string $class
CreationContext $context
mixed $items

Return Value

Enumerable

at line 349
protected LazyCollection deferCollectionItems(string $class, CreationContext $context, LazyCollection $source)

Create a deferred item collection with one shared operation memo.

Parameters

string $class
CreationContext $context
LazyCollection $source

Return Value

LazyCollection

at line 378
protected BaseData createUnvalidatedNode(string $class, CreationContext $context, array $payloads, CreationExtensions $extensions)

Create one nested node without restarting root validation or authorization.

Parameters

string $class
CreationContext $context
array $payloads

caller keys remain meaningful until named factory matching

CreationExtensions $extensions

Return Value

BaseData

at line 439
protected array|DataCollection|PaginatedDataCollection|CursorPaginatedDataCollection|Enumerable|AbstractPaginator|Paginator|AbstractCursorPaginator|CursorPaginator|LazyCollection|Collection collectEager(string $class, CreationContext $context, mixed $source, array $values, string|null $into, bool $shouldValidate)

Collect an eager source through one Fill and validation graph.

Parameters

string $class
CreationContext $context
mixed $source
array $values
string|null $into
bool $shouldValidate

Return Value

array|DataCollection|PaginatedDataCollection|CursorPaginatedDataCollection|Enumerable|AbstractPaginator|Paginator|AbstractCursorPaginator|CursorPaginator|LazyCollection|Collection

at line 475
protected array createEagerCollectionItems(string $class, CreationContext $context, mixed $source, array $values, bool $shouldValidate)

Create every eager item through one Fill and validation graph.

Parameters

string $class
CreationContext $context
mixed $source
array $values
bool $shouldValidate

Return Value

array

at line 541
protected void loadMissingRelations(string $class, Collection $models)

Batch relations explicitly selected by data properties.

Parameters

string $class
Collection $models

Return Value

void

at line 571
protected void fillCollectionItems(string $class, array $values, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate)

Fill every eager root collection item into one construction state.

Parameters

string $class
array $values
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate

Return Value

void

at line 613
protected array castCollectionItems(string $class, ConstructionState $state, CreationExtensions $extensions)

Cast and instantiate every eager root collection item.

Parameters

string $class
ConstructionState $state
CreationExtensions $extensions

Return Value

array

at line 646
protected BaseData|array execute(string $class, CreationContext $context, array $payloads)

Run the fixed operation through its selected exit point.

Parameters

string $class
CreationContext $context
array $payloads

Return Value

BaseData|array

at line 738
protected BaseData|null fillNode(string $class, array $payloads, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Normalize and fill one data node into the root construction state.

Factory matching consumes caller keys. Every later source-indexed operation receives a list.

Parameters

string $class
array $payloads

caller keys remain meaningful until named factory matching

ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules

Return Value

BaseData|null

at line 806
protected bool fillGeneralNode(DataClass $dataClass, array $payloads, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Fill one post-factory value through the general construction path.

Parameters

DataClass $dataClass
array $payloads
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules

Return Value

bool

false when nested input could not be read and was kept as given

at line 918
protected BaseData|null tryCreateDirectArrayNode(DataClass $dataClass, array $payloads, CreationContext $context, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Create one fixed array node without entering the general Fill path.

The complete node is checked before conversion so a later miss cannot repeat a nested factory, hook, or constructor when the caller enters general Fill.

Parameters

DataClass $dataClass
array $payloads
CreationContext $context
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules

Return Value

BaseData|null

at line 1051
protected BaseData|null fillHookNode(string $class, mixed $payload, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Fill one node introduced or changed by a validation payload hook.

Parameters

string $class
mixed $payload
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules

Return Value

BaseData|null

at line 1118
protected void fillConstructorInputs(DataClass $dataClass, array $sources, ConstructionState $state)

Write the raw input of constructor parameters that have no public data property.

Parameters

DataClass $dataClass
array $sources
ConstructionState $state

Return Value

void

at line 1139
protected void fillResolvedProperties(DataClass $dataClass, array $resolvedProperties, array $sources, array $payloads, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules, bool $fromValidationHook)

Write one resolved data node and recursively fill its declared children.

Parameters

DataClass $dataClass
array $resolvedProperties
array $sources
array $payloads
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules
bool $fromValidationHook

Return Value

void

at line 1258
protected void fillResolvedProperty(DataProperty $property, array $inputPath, mixed $value, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules, bool $fromValidationHook)

Write one resolved property and recursively fill its declared children.

Parameters

DataProperty $property
array $inputPath
mixed $value
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules
bool $fromValidationHook

Return Value

void

at line 1441
protected void applyPayloadHooks(string $class, array $hooks, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules, bool $reconcile = true, bool $collection = false)

Apply one root payload-hook stage and reconcile changed selections.

Parameters

string $class
array $hooks
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules
bool $reconcile
bool $collection

Return Value

void

at line 1496
protected void reconcileCollection(string $class, array $previousPayload, array $payload, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Reconcile changed eager root collection items.

Parameters

string $class
array $previousPayload
array $payload
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules

Return Value

void

at line 1578
protected void reconcileNode(string $declaredClass, array $previousPayload, array $payload, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Reconcile one changed assembled data node without replaying prepare hooks.

Parameters

string $declaredClass
array $previousPayload
array $payload
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules

Return Value

void

at line 1686
protected void rematchDeferredFactory(DataClass $dataClass, array $payload, ConstructionState $state)

Match the named factory again for a node beneath a cast whose input a validation hook replaced.

A recorded match holds the earlier input, so it no longer describes the node.

Parameters

DataClass $dataClass
array $payload
ConstructionState $state

Return Value

void

at line 1703
protected void reconcileProperty(DataProperty $property, mixed $previousValue, mixed $value, string|int $wireKey, array $payload, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Reconcile one changed property selection.

Parameters

DataProperty $property
mixed $previousValue
mixed $value
string|int $wireKey
array $payload
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules

Return Value

void

at line 1898
protected void reconcileDataIterable(DataProperty $property, NamedType $type, mixed $previousValue, mixed $value, array $inputPath, ConstructionState $state, CreationExtensions $extensions, bool $shouldValidate, bool $compilesRules)

Reconcile one changed typed data iterable.

Parameters

DataProperty $property
NamedType $type
mixed $previousValue
mixed $value
array $inputPath
ConstructionState $state
CreationExtensions $extensions
bool $shouldValidate
bool $compilesRules

Return Value

void

at line 2013
protected BaseData castAndInstantiateNode(ConstructionState $state, CreationExtensions $extensions)

Cast and instantiate the node at the current construction path.

Parameters

ConstructionState $state
CreationExtensions $extensions

Return Value

BaseData

at line 2198
protected mixed buildAutoLazy(DataProperty $property, mixed $value, ConstructionState $state, CreationExtensions $extensions, array $properties = [], array|null $castInputs = null)

Build one automatic lazy property around the ordinary cast path.

Parameters

DataProperty $property
mixed $value
ConstructionState $state
CreationExtensions $extensions
array $properties
array|null $castInputs

Return Value

mixed

at line 2251
protected mixed castProperty(DataProperty $property, mixed $value, ConstructionState $state, CreationExtensions $extensions, array $properties = [], array|null $castInputs = null)

Cast one supplied property value.

Parameters

DataProperty $property
mixed $value
ConstructionState $state
CreationExtensions $extensions
array $properties
array|null $castInputs

Return Value

mixed

at line 2440
protected mixed castDataIterable(DataProperty $property, NamedType $type, mixed $value, ConstructionState $state, CreationExtensions $extensions)

Cast every item in one declared data iterable.

Parameters

DataProperty $property
NamedType $type
mixed $value
ConstructionState $state
CreationExtensions $extensions

Return Value

mixed

at line 2517
protected mixed castTypedIterable(DataProperty $property, NamedType $type, mixed $value, ConstructionState $state, CreationExtensions $extensions, array $casts, array $properties, array|null $castInputs)

Cast every item in one declared non-data iterable.

Parameters

DataProperty $property
NamedType $type
mixed $value
ConstructionState $state
CreationExtensions $extensions
array $casts
array $properties
array|null $castInputs

Return Value

mixed

at line 2591
protected mixed castIterableItem(DataProperty $property, Type $type, mixed $value, ConstructionState $state, CreationExtensions $extensions, array $casts, array $castInputs)

Cast one declared iterable item.

Parameters

DataProperty $property
Type $type
mixed $value
ConstructionState $state
CreationExtensions $extensions
array $casts
array $castInputs

Return Value

mixed

at line 2679
protected array castInputs(ConstructionState $state, array $properties)

Build the declared property values a user cast receives for the current node.

Values already cast for this node are used as they are, other supplied input stays raw, and absent properties resolve as construction would resolve them. Contextual constructor values are excluded.

Parameters

ConstructionState $state
array $properties

values already cast for this node

Return Value

array

at line 2718
protected bool requiresCastInputs(DataProperty $property, CreationContext $context, CreationExtensions $extensions)

Determine if casting a property can reach a user cast that receives the declared values.

Parameters

DataProperty $property
CreationContext $context
CreationExtensions $extensions

Return Value

bool

at line 2747
protected bool hasCastableType(Type $type)

Determine if a type accepts a Castable class.

Parameters

Type $type

Return Value

bool

at line 2764
protected bool isCastOwned(DataProperty $property, CreationContext $context, CreationExtensions $extensions)

Determine if casts own the construction of a data object or collection property.

Casts receive such a value before any of its objects are built. Under validation it is prepared and validated first, while its named factories and constructors wait until the casts decline it.

Parameters

DataProperty $property
CreationContext $context
CreationExtensions $extensions

Return Value

bool

at line 2777
protected array resolveProperties(DataClass $dataClass, array $sources, CreationContext $context, bool $compilesRules)

Resolve every declared property against the normalized sources.

Parameters

DataClass $dataClass
array $sources
CreationContext $context
bool $compilesRules

Return Value

array

at line 2798
protected array resolveProperty(array $sources, DataProperty $property, CreationContext $context, bool $compilesRules)

Resolve one property from the last source that supplies it, with mapped-key precedence inside each source.

Parameters

array $sources
DataProperty $property
CreationContext $context
bool $compilesRules

Return Value

array

at line 2833
protected mixed resolveAutoLazySource(DataProperty $property, array $sources, array $payloads, CreationContext $context, bool $compilesRules)

Resolve the raw source aligned with one automatic lazy property.

Parameters

DataProperty $property
array $sources
array $payloads
CreationContext $context
bool $compilesRules

Return Value

mixed

at line 2871
protected array|null matchPropertySource(array|Normalized $source, DataProperty $property, string|int $mappedKey, bool $compilesRules)

Match one property against one normalized source.

Validated input must use the mapped name, as its rules do. Otherwise, as upstream, the PHP property name is read when the mapped name is missing.

Parameters

array|Normalized $source
DataProperty $property
string|int $mappedKey
bool $compilesRules

Return Value

array|null

at line 2897
protected string|int propertyInputKey(DataProperty $property, CreationContext $context)

Get the effective input key for one property.

Parameters

DataProperty $property
CreationContext $context

Return Value

string|int

at line 2914
protected array prepareSourcesForPipeline(DataClass $dataClass, array $sources, CreationContext $context, bool $compilesRules)

Pass each normalized source through the class's prepareForPipeline() method.

A model source is first projected to its declared properties, as upstream does.

Parameters

DataClass $dataClass
array $sources
CreationContext $context
bool $compilesRules

Return Value

array

at line 2942
protected array prepareDataInput(DataClass $dataClass, array $sources, array $resolvedProperties, CreationContext $context, bool $compilesRules)

Build the prepare-data hook input from the values property resolution selects.

Later array sources supply undeclared keys. Each declared property's selected value is written under the spelling resolution reads first, so a hook that returns its input changes nothing.

Parameters

DataClass $dataClass
array $sources
array $resolvedProperties
CreationContext $context
bool $compilesRules

Return Value

array

at line 2987
protected array mergeArraySources(array $sources)

Merge the array sources, with later sources taking precedence.

Parameters

array $sources

Return Value

array

at line 3006
protected array mergeSources(DataClass $dataClass, array $sources, CreationContext $context, bool $compilesRules)

Merge the keys of every normalized source for unknown-field detection.

Parameters

DataClass $dataClass
array $sources
CreationContext $context
bool $compilesRules

Return Value

array

at line 3029
protected array projectNormalizedSource(DataClass $dataClass, Normalized $source, CreationContext $context, bool $compilesRules)

Project a non-enumerable normalized source into declared wire keys.

Parameters

DataClass $dataClass
Normalized $source
CreationContext $context
bool $compilesRules

Return Value

array

at line 3061
protected array mergeMissingValues(array $target, array $source)

Recursively fill only values absent from the earlier source.

Parameters

array $target
array $source

Return Value

array

at line 3084
protected array|null matchNamedFactory(DataClass $dataClass, CreationContext $context, array $payloads)

Find the first compatible named object factory.

Parameters

DataClass $dataClass
CreationContext $context
array $payloads

Return Value

array|null

at line 3118
protected BaseData|array resolveFactoryPayloads(DataClass $dataClass, CreationContext $context, array $payloads)

Create the object with a matching named factory, or list the payloads for ordinary creation.

Caller keys remain meaningful through factory matching and are discarded afterwards.

Parameters

DataClass $dataClass
CreationContext $context
array $payloads

Return Value

BaseData|array

at line 3135
protected array|null matchNamedCollectionFactory(DataClass $dataClass, CreationContext $context, mixed $items, string|null $into)

Find the first compatible named collection factory.

Parameters

DataClass $dataClass
CreationContext $context
mixed $items
string|null $into

Return Value

array|null

at line 3166
protected mixed invokeNamedFactory(DataClass $dataClass, DataMethod $method, DataMethodMatch $match)

Invoke one matched named factory without method-binding interception.

Parameters

DataClass $dataClass
DataMethod $method
DataMethodMatch $match

Return Value

mixed

at line 3182
protected BaseData invokeNamedObjectFactory(DataClass $dataClass, DataMethod $method, DataMethodMatch $match)

Invoke one matched named object factory, which must return the requested object.

Parameters

DataClass $dataClass
DataMethod $method
DataMethodMatch $match

Return Value

BaseData

at line 3205
protected string resolveMorphClass(DataClass $dataClass, array $resolvedProperties, bool $compilesRules)

Resolve the concrete class selected by an abstract property's discriminator.

When rules compile, a missing discriminator or a null morph() result keeps the abstract class, so validation reports the discriminator instead of creation failing.

Parameters

DataClass $dataClass
array $resolvedProperties
bool $compilesRules

Return Value

string

at line 3271
protected mixed propertyDefaultValue(DataClass $dataClass, DataProperty $property)

Materialize a property default only when morph selection requires it.

Parameters

DataClass $dataClass
DataProperty $property

Return Value

mixed

at line 3293
protected bool requiresAutoLazyReplay(DataProperty $property, CreationContext $context, CreationExtensions $extensions)

Determine if an automatic lazy property needs deferred Fill replay.

Parameters

DataProperty $property
CreationContext $context
CreationExtensions $extensions

Return Value

bool

at line 3322
protected bool isAutoWhenLoaded(DataProperty $property)

Determine if a property uses model relation automatic lazy loading.

Parameters

DataProperty $property

Return Value

bool

at line 3334
protected NamedType|null selectType(DataProperty $property, mixed $value, ConstructionState $state)

Select and record the declared type that receives a union value.

The one container type accepting the value receives it. Otherwise a value no declared type accepts selects the data object type, and any other value is kept.

Parameters

DataProperty $property
mixed $value
ConstructionState $state

Return Value

NamedType|null

at line 3352
protected void retainPaginatorSource(DataProperty $property, NamedType $type, mixed $value, array $inputPath, ConstructionState $state)

Retain source metadata for one declared paginator property.

Parameters

DataProperty $property
NamedType $type
mixed $value
array $inputPath
ConstructionState $state

Return Value

void

at line 3377
protected array|null iterableValues(mixed $value)

Convert an eager iterable to its keyed values.

Parameters

mixed $value

Return Value

array|null