Skip to content

Commit 63eea10

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: Clarify MapRequestPayload with nested arrays
2 parents 7109eea + 18042fa commit 63eea10

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

controller.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,29 @@ the validation fails as well as supported payload formats::
523523
// ...
524524
}
525525

526+
526527
The default status code returned if the validation fails is 422.
527528

529+
Make sure to install `phpstan/phpdoc-parser`_ and `phpdocumentor/type-resolver`_
530+
if you want to map a nested array of specific DTOs::
531+
532+
public function dashboard(
533+
#[MapRequestPayload()] EmployeesDTO $employeesDto
534+
): Response
535+
{
536+
// ...
537+
}
538+
539+
final class EmployeesDTO
540+
{
541+
/**
542+
* @param UserDTO[] $users
543+
*/
544+
public function __construct(
545+
public readonly array $users = []
546+
) {}
547+
}
548+
528549
.. versionadded:: 6.3
529550

530551
The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapRequestPayload` attribute
@@ -798,3 +819,5 @@ Learn more about Controllers
798819
.. _`SAPI`: https://www.php.net/manual/en/function.php-sapi-name.php
799820
.. _`FrankenPHP`: https://frankenphp.dev
800821
.. _`Validate Filters`: https://www.php.net/manual/en/filter.filters.validate.php
822+
.. _`phpstan/phpdoc-parser`: https://packagist.org/packages/phpstan/phpdoc-parser
823+
.. _`phpdocumentor/type-resolver`: https://packagist.org/packages/phpdocumentor/type-resolver

0 commit comments

Comments
 (0)