-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected
6.4.2 (Other versions most likely as well)
Description
For some reason the serializer doesn't seem to like variadic arguments in the constructor
How to reproduce
When deserializing a json object like this
{
"requiredParameter": "required",
"optionalParameter": "optional",
"variadicParameter": [
{"param": 1},
{"param": 2}
]
}
into a PHP class like this
class ChildExample {
public function __construct(
private int $param,
) {}
}
class Example {
private array $variadicProperty;
public function __construct(
private string $requiredParameter,
private string $optionalParameter = '',
SomeClass ...$variadicParameter,
) {
$this->variadicProperty = $variadicParameter;
}
}
I get the PHP error Error : Cannot use positional argument after named argument
on line 429 of AbstractNormalizer.php
.
Possible Solution
When I wrap the $params
variable in an array_values()
call the problem goes away. I'll try to create a pull request with my fix later.
Additional Context
No response
ruudk, gsdevme and webmake