|
|
@@ -226,7 +226,7 @@ class FormContext implements FormContextInterface
|
|
|
|
is_null($value) => null,
|
|
|
|
is_null($value) => null,
|
|
|
|
enum_exists($e) => ( $value instanceof \BackedEnum ? $value : $e::tryFrom($value) ) ?? throw new \InvalidArgumentException(sprintf("Field '\$$property' awaiting values : '%s'.", implode("', '", array_map(fn($e) => $e->value, $e::cases())))),
|
|
|
|
enum_exists($e) => ( $value instanceof \BackedEnum ? $value : $e::tryFrom($value) ) ?? throw new \InvalidArgumentException(sprintf("Field '\$$property' awaiting values : '%s'.", implode("', '", array_map(fn($e) => $e->value, $e::cases())))),
|
|
|
|
function_exists($e) => $e($value),
|
|
|
|
function_exists($e) => $e($value),
|
|
|
|
class_exists($e) => new $e(...$value),
|
|
|
|
class_exists($e) => is_array($value) ? new $e(...$value) : new $e($value),
|
|
|
|
interface_exists($e) => throw new \InvalidArgumentException("There is no way provided to match an interface object yet."),
|
|
|
|
interface_exists($e) => throw new \InvalidArgumentException("There is no way provided to match an interface object yet."),
|
|
|
|
default => $value
|
|
|
|
default => $value
|
|
|
|
};
|
|
|
|
};
|
|
|
@@ -238,11 +238,12 @@ class FormContext implements FormContextInterface
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($types instanceof \ReflectionIntersectionType || $types instanceof \ReflectionUnionType) {
|
|
|
|
elseif ($types instanceof \ReflectionIntersectionType || $types instanceof \ReflectionUnionType) {
|
|
|
|
foreach($types->getTypes() as $type) {
|
|
|
|
foreach($types->getTypes() as $type) {
|
|
|
|
return $cast($type->getName());
|
|
|
|
$value = $cast($type->getName());
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($types->isBuiltin()) {
|
|
|
|
elseif ($types->isBuiltin()) {
|
|
|
|
return $cast($types->getName());
|
|
|
|
$value = $cast($types->getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $value;
|
|
|
|
return $value;
|
|
|
|