From e1ba05a66dc1f1eb90607775434848c86b00a504 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Thu, 22 Oct 2026 15:17:57 +0000 Subject: [PATCH] - Fixed a bug within FormContext while unpacking arguments for an object when no array were given --- src/Method/FormContext.php | 7 ++++--- src/Method/FormHandler.php | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Method/FormContext.php b/src/Method/FormContext.php index 2b84bd4..647e3f7 100644 --- a/src/Method/FormContext.php +++ b/src/Method/FormContext.php @@ -226,7 +226,7 @@ class FormContext implements FormContextInterface 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())))), 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."), default => $value }; @@ -238,11 +238,12 @@ class FormContext implements FormContextInterface } elseif ($types instanceof \ReflectionIntersectionType || $types instanceof \ReflectionUnionType) { foreach($types->getTypes() as $type) { - return $cast($type->getName()); + $value = $cast($type->getName()); + break; } } elseif ($types->isBuiltin()) { - return $cast($types->getName()); + $value = $cast($types->getName()); } return $value; diff --git a/src/Method/FormHandler.php b/src/Method/FormHandler.php index e6279a3..6f9d8ed 100644 --- a/src/Method/FormHandler.php +++ b/src/Method/FormHandler.php @@ -13,6 +13,7 @@ class FormHandler { public bool $validateCsrfToken = true; + # in PHP 8.5, value should be taken directly from a property get within $context->formExecutionStatus public /* mixed */ $executionStatus = null; public ? bool $validationStatus = null;