From bec480a1eb45cbe15cc4d13a0fbb738282d57736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20L=C3=ADbal?= Date: Thu, 25 Jun 2026 11:16:00 +0200 Subject: [PATCH] Form: getHttpData() return type reflects the $htmlName argument --- src/Forms/Form.php | 2 +- tests/types/forms-types.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Forms/Form.php b/src/Forms/Form.php index 63088138..54cdbe0a 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -439,7 +439,7 @@ public function setSubmittedBy(?SubmitterControl $by): static /** * Returns raw submitted HTTP data for a control, or all form data when called without arguments. - * @return string|string[]|Nette\Http\FileUpload|null + * @return ($htmlName is null ? mixed[] : string|string[]|Nette\Http\FileUpload|Nette\Http\FileUpload[]|null) */ public function getHttpData(?int $type = null, ?string $htmlName = null): string|array|Nette\Http\FileUpload|null { diff --git a/tests/types/forms-types.php b/tests/types/forms-types.php index e88ee6c5..ce9433f9 100644 --- a/tests/types/forms-types.php +++ b/tests/types/forms-types.php @@ -50,3 +50,11 @@ function testFormEvents(Form $form): void assertType(Form::class, $form); }; } + + +// Issue #351: getHttpData() without arguments returns the whole nested data, not string[] +function testFormGetHttpData(Form $form): void +{ + assertType('array', $form->getHttpData()); + assertType('array|Nette\Http\FileUpload|string|null', $form->getHttpData(Form::DataLine, 'name')); +}