class DataCreator

Properties

protected CreationContext> $defaultContexts

Methods

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

Create a data creator.

factory(string $class)

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)

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, array $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, array $extensions, bool $shouldValidate)

Fill every eager root collection item into one construction state.

array
castCollectionItems(string $class, ConstructionState $state, array $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, array $extensions, bool $shouldValidate, bool $compilesRules)

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

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

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

BaseData|null
tryCreateDirectArrayNode(DataClass $dataClass, array $payloads, CreationContext $context, array $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, array $extensions, bool $shouldValidate, bool $compilesRules)

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

void
fillResolvedProperties(DataClass $dataClass, array $resolvedProperties, array $sources, array $payloads, ConstructionState $state, array $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, array $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, array $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, array $extensions, bool $shouldValidate, bool $compilesRules)

Reconcile changed eager root collection items.

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

Reconcile one changed assembled data node without replaying prepare hooks.

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

Reconcile one changed property selection.

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

Reconcile one changed typed data iterable.

castAndInstantiateNode(ConstructionState $state, array $extensions)

Cast and instantiate the node at the current construction path.

mixed
buildAutoLazy(DataProperty $property, mixed $value, ConstructionState $state, array $extensions)

Build one automatic lazy property around the ordinary cast path.

mixed
castProperty(DataProperty $property, mixed $value, ConstructionState $state, array $extensions)

Cast one supplied property value.

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

Cast every item in one declared data iterable.

mixed
castTypedIterable(DataProperty $property, NamedType $type, mixed $value, ConstructionState $state, array $extensions, array $casts)

Cast every item in one declared non-data iterable.

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

Cast one declared iterable item.

resolveAutoLazy(DataProperty $property, array $extensions)

Resolve one automatic lazy attribute for the current root operation.

array
propertyCasts(DataProperty $property, CreationContext $context, array $extensions)

Get the ordered custom casts applicable to a property.

resolveCast(Cast|string $cast, array $extensions)

Resolve one cast once for the current root operation.

array
resolveNormalizers(DataClass $dataClass, CreationContext $context, array $extensions)

Resolve the custom normalizers for one data class.

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

Resolve every declared property against the normalized sources.

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

Resolve one property with mapped-key precedence inside each source.

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

Resolve the raw source aligned with one automatic lazy property.

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

Match one property against one normalized source.

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

Get the effective input key for one property.

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

Merge normalized sources for a prepare-data hook.

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

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)

Resolve a named factory and normalize its remaining payloads.

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.

string
resolveMorphClass(DataClass $dataClass, array $resolvedProperties)

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)

Determine if an automatic lazy property needs deferred Fill replay.

bool
isAutoWhenLoaded(DataProperty $property)

Determine if a property uses model relation automatic lazy loading.

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 72
__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 90
CreationContextFactory factory(string $class)

Create a fresh construction factory for a data class.

Parameters

string $class

Return Value

CreationContextFactory

at line 112
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 130
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 148
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 164
mixed resolveAutoLazyProperty(string $propertyName, mixed $value, ConstructionState $state, AutoLazyReplayMode|null $replay)

internal  
 

Resolve one deferred automatic lazy property.

Parameters

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

Return Value

mixed

at line 207
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.

at line 250
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 321
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 351
protected BaseData createUnvalidatedNode(string $class, CreationContext $context, array $payloads, array $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

array $extensions

Return Value

BaseData

at line 412
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 448
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 514
protected void loadMissingRelations(string $class, Collection $models)

Batch relations explicitly selected by data properties.

Parameters

string $class
Collection $models

Return Value

void

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

Fill every eager root collection item into one construction state.

Parameters

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

Return Value

void

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

Cast and instantiate every eager root collection item.

Parameters

string $class
ConstructionState $state
array $extensions

Return Value

array

at line 621
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 714
protected BaseData|null fillNode(string $class, array $payloads, ConstructionState $state, array $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
array $extensions
bool $shouldValidate
bool $compilesRules

Return Value

BaseData|null

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

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

Parameters

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

Return Value

void

at line 833
protected BaseData|null tryCreateDirectArrayNode(DataClass $dataClass, array $payloads, CreationContext $context, array $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
array $extensions
bool $shouldValidate
bool $compilesRules

Return Value

BaseData|null

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

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

Parameters

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

Return Value

BaseData|null

at line 1014
protected void fillResolvedProperties(DataClass $dataClass, array $resolvedProperties, array $sources, array $payloads, ConstructionState $state, array $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
array $extensions
bool $shouldValidate
bool $compilesRules
bool $fromValidationHook

Return Value

void

at line 1113
protected void fillResolvedProperty(DataProperty $property, array $inputPath, mixed $value, ConstructionState $state, array $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
array $extensions
bool $shouldValidate
bool $compilesRules
bool $fromValidationHook

Return Value

void

at line 1255
protected void applyPayloadHooks(string $class, array $hooks, ConstructionState $state, array $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
array $extensions
bool $shouldValidate
bool $compilesRules
bool $reconcile
bool $collection

Return Value

void

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

Reconcile changed eager root collection items.

Parameters

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

Return Value

void

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

Reconcile one changed assembled data node without replaying prepare hooks.

Parameters

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

Return Value

void

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

Reconcile one changed property selection.

Parameters

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

Return Value

void

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

Reconcile one changed typed data iterable.

Parameters

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

Return Value

void

at line 1746
protected BaseData castAndInstantiateNode(ConstructionState $state, array $extensions)

Cast and instantiate the node at the current construction path.

Parameters

ConstructionState $state
array $extensions

Return Value

BaseData

at line 1829
protected mixed buildAutoLazy(DataProperty $property, mixed $value, ConstructionState $state, array $extensions)

Build one automatic lazy property around the ordinary cast path.

Parameters

DataProperty $property
mixed $value
ConstructionState $state
array $extensions

Return Value

mixed

at line 1874
protected mixed castProperty(DataProperty $property, mixed $value, ConstructionState $state, array $extensions)

Cast one supplied property value.

Parameters

DataProperty $property
mixed $value
ConstructionState $state
array $extensions

Return Value

mixed

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

Cast every item in one declared data iterable.

Parameters

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

Return Value

mixed

at line 2105
protected mixed castTypedIterable(DataProperty $property, NamedType $type, mixed $value, ConstructionState $state, array $extensions, array $casts)

Cast every item in one declared non-data iterable.

Parameters

DataProperty $property
NamedType $type
mixed $value
ConstructionState $state
array $extensions
array $casts

Return Value

mixed

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

Cast one declared iterable item.

Parameters

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

Return Value

mixed

at line 2259
protected AutoLazy resolveAutoLazy(DataProperty $property, array $extensions)

Resolve one automatic lazy attribute for the current root operation.

Parameters

DataProperty $property
array $extensions

Return Value

AutoLazy

at line 2280
protected array propertyCasts(DataProperty $property, CreationContext $context, array $extensions)

Get the ordered custom casts applicable to a property.

Parameters

DataProperty $property
CreationContext $context
array $extensions

Return Value

array

at line 2318
protected Cast resolveCast(Cast|string $cast, array $extensions)

Resolve one cast once for the current root operation.

Parameters

Cast|string $cast
array $extensions

Return Value

Cast

at line 2336
protected array resolveNormalizers(DataClass $dataClass, CreationContext $context, array $extensions)

Resolve the custom normalizers for one data class.

Parameters

DataClass $dataClass
CreationContext $context
array $extensions

Return Value

array

at line 2395
protected array resolveProperties(DataClass $dataClass, array $sources, CreationContext $context)

Resolve every declared property against the normalized sources.

Parameters

DataClass $dataClass
array $sources
CreationContext $context

Return Value

array

at line 2415
protected array resolveProperty(array $sources, DataProperty $property, CreationContext $context)

Resolve one property with mapped-key precedence inside each source.

Parameters

array $sources
DataProperty $property
CreationContext $context

Return Value

array

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

Resolve the raw source aligned with one automatic lazy property.

Parameters

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

Return Value

mixed

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

Match one property against one normalized source.

Parameters

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

Return Value

array|null

at line 2496
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 2511
protected array mergeSources(DataClass $dataClass, array $sources, CreationContext $context)

Merge normalized sources for a prepare-data hook.

Parameters

DataClass $dataClass
array $sources
CreationContext $context

Return Value

array

at line 2533
protected array projectNormalizedSource(DataClass $dataClass, Normalized $source, CreationContext $context)

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

Parameters

DataClass $dataClass
Normalized $source
CreationContext $context

Return Value

array

at line 2564
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 2587
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 2621
protected BaseData|array resolveFactoryPayloads(DataClass $dataClass, CreationContext $context, array $payloads)

Resolve a named factory and normalize its remaining payloads.

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

Parameters

DataClass $dataClass
CreationContext $context
array $payloads

Return Value

BaseData|array

at line 2645
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 2676
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 2695
protected string resolveMorphClass(DataClass $dataClass, array $resolvedProperties)

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

Parameters

DataClass $dataClass
array $resolvedProperties

Return Value

string

at line 2753
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 2775
protected bool requiresAutoLazyReplay(DataProperty $property)

Determine if an automatic lazy property needs deferred Fill replay.

Parameters

DataProperty $property

Return Value

bool

at line 2792
protected bool isAutoWhenLoaded(DataProperty $property)

Determine if a property uses model relation automatic lazy loading.

Parameters

DataProperty $property

Return Value

bool

at line 2803
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 2828
protected array|null iterableValues(mixed $value)

Convert an eager iterable to its keyed values.

Parameters

mixed $value

Return Value

array|null