Skip to content

RequestDtoProperty

One constructor-promoted property of a #[MapRequest] DTO, as reflected by RequestDtoScanner.

Carries everything RequestDtoMapper needs to pull a value back out of an already-validated WebRequest and cast it to the property’s declared PHP type.

final class RequestDtoProperty

Since1.0.0
SourceRequest/Compiler/RequestDtoProperty.php
PropertyTypeDescription
$defaultValuemixedreadonly.
$enumClass?``stringreadonly.
$hasDefaultboolreadonly.
$kindstringreadonly.
$namestringreadonly.
$nullableboolreadonly.

public function __construct(string $name, 'string'|'int'|'float'|'bool'|'array'|'datetime'|'enum' $kind, bool $nullable, bool $hasDefault, mixed $defaultValue, ?class-string $enumClass = null): mixed

Set only when $kind === ‘enum’.

ParameterTypeDescription
$namestring
$kind`‘string’“'int'
$nullablebool
$hasDefaultbool
$defaultValuemixed
$enumClass?``class-stringSet only when $kind === ‘enum’.

Returns mixed

MethodDescription
isRequired(): boolReports whether the mapper has to find a value for this property.

public function isRequired(): bool

Reports whether the mapper has to find a value for this property.

True only when the property is neither nullable nor has a constructor default: in either of those cases the DTO can still be built without an incoming value.

Returns bool