Repository: symfony/symfony
File: src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php (PHP)

Code before:

        try {
            return $this->serializer->deserialize($data, $type, $format, self::CONTEXT_DESERIALIZE + $attribute->serializationContext);
        } catch (UnsupportedFormatException $e) {
            throw new UnsupportedMediaTypeHttpException(\sprintf('Unsupported format: "%s".', $format), $e);
        } catch (NotEncodableValueException $e) {
            throw new BadRequestHttpException(\sprintf('Request payload contains invalid "%s" data.', $format), $e);
        } catch (UnexpectedPropertyException $e) {
            throw new BadRequestHttpException(\sprintf('Request payload contains invalid "%s" property.', $e->property), $e);
        }
    }

    private function mapUploadedFile(Request $request, ArgumentMetadata $argument, MapUploadedFile $attribute): UploadedFile|array|null
    {
        return $request->files->get($attribute->name ?? $argument->getName(), []);
    }

    /**
     * @param Expression|string|GroupSequence|array<string|Expression>|null $validationGroups
     *
     * @return string|GroupSequence|array<string>|null
     */
    private function resolveValidationGroups(
        Expression|string|GroupSequence|array|null $validationGroups,
        ControllerArgumentsEvent $event,
    ): string|GroupSequence|array|null {
        if ($validationGroups instanceof Expression) {
            return $this->resolveExpression($validationGroups, $event);
        }

        if (\is_array($validationGroups)) {
            return array_map(
                function (string|Expression $validationGroup) use ($event) {
                    if ($validationGroup instanceof Expression) {
                        return $this->resolveExpression($validationGroup, $event);
                    }

                    return $validationGroup;
                },
                $validationGroups
            );
        }

        return $validationGroups;
    }

    private function resolveExpression(Expression $expression, ControllerArgumentsEvent $event): string
    {
        return $this->getExpressionLanguage()->evaluate($expression, [
            'request' => $event->getRequest(),
            'args' => $event->getNamedArguments(),

Review comment (suggestion):
```suggestion
    private function resolveValidationGroups(Expression|string|GroupSequence|array|null $validationGroups, ControllerArgumentsEvent $event): string|GroupSequence|array|null {
```

Code after:
            throw new BadRequestHttpException('Request payload contains invalid "form" data.');
        }

        try {
            return $this->serializer->deserialize($data, $type, $format, self::CONTEXT_DESERIALIZE + $attribute->serializationContext);
        } catch (UnsupportedFormatException $e) {
            throw new UnsupportedMediaTypeHttpException(\sprintf('Unsupported format: "%s".', $format), $e);
        } catch (NotEncodableValueException $e) {
            throw new BadRequestHttpException(\sprintf('Request payload contains invalid "%s" data.', $format), $e);
        } catch (UnexpectedPropertyException $e) {
            throw new BadRequestHttpException(\sprintf('Request payload contains invalid "%s" property.', $e->property), $e);
        }
    }

    private function mapUploadedFile(Request $request, ArgumentMetadata $argument, MapUploadedFile $attribute): UploadedFile|array|null
    {
        if (!($files = $request->files->get($attribute->name ?? $argument->getName())) && ($argument->isNullable() || $argument->hasDefaultValue())) {
            return null;
        }

        return $files ?? ('array' === $argument->getType() ? [] : null);
    }

    private function mergeParamsAndFiles(array $params, array $files): array
    {
        $isFilesList = array_is_list($files);

        foreach ($params as $key => $value) {
            if (\is_array($value) && \is_array($files[$key] ?? null)) {
                $params[$key] = $this->mergeParamsAndFiles($value, $files[$key]);
                unset($files[$key]);
            }
        }

        if (!$isFilesList) {
            return array_replace($params, $files);
        }

        foreach ($files as $value) {
            $params[] = $value;
        }

        return $params;
    }

    private function resolveValidationGroups(Expression|string|GroupSequence|\Closure|array|null $validationGroups, ControllerArgumentsEvent $event): string|GroupSequence|array|null
    {
        $controller = $event->getController();
        $controller = match (true) {
            \is_object($controller) => $controller,
            \is_array($controller) && \is_object($controller[0]) => $controller[0],