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

Code before:
     * @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(),
        ]);
    }

    private function getExpressionLanguage(): ExpressionLanguage
    {
        return $this->expressionLanguage ?? new ExpressionLanguage();
    }
}


Review comment (suggestion):
```suggestion
        if (!\is_array($validationGroups)) {
            return $validationGroups;
        }

        return array_map(fn ($group) => $group instanceof Expression ? $this->resolveExpression($group, $event) : $group, $validationGroups);
        }

```

Code after:
        }

        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],
            default => null,
        };

        if ($validationGroups instanceof Expression) {
            $validationGroups = $this->getExpressionLanguage()->evaluate($validationGroups, [
                'request' => $event->getRequest(),
                'args' => $event->getNamedArguments(),
                'this' => $controller,
            ]);
        }

        if ($validationGroups instanceof \Closure) {
            $validationGroups = $validationGroups($event->getNamedArguments(), $event->getRequest(), $controller);
        }

        if (null === $validationGroups || \is_string($validationGroups) || $validationGroups instanceof GroupSequence) {
            return $validationGroups;
        }