Closed as not planned
Closed as not planned
Description
Description
The Serializer is perfectly capable of deserializing the following object without configuration:
final class CreateUserCommand
{
private function __construct(
public string $firstName,
public string $lastName,
) {}
}
But as soon as you make the class readonly
(PHP 8.2 feature) or make the constructor properties readonly
(PHP 8.1) you'll get an error:
Error : Cannot initialize readonly property CreateUserCommand::$firstName from scope Symfony\Component\PropertyAccess\PropertyAccessor
/Volumes/CS/www/cosmos/vendor/symfony/property-access/PropertyAccessor.php:530
final readonly class CreateUserCommand
{
private function __construct(
public string $firstName,
public string $lastName,
) {}
}
final class CreateUserCommand
{
private function __construct(
public readonly string $firstName,
public readonly string $lastName,
) {}
}
Example
No response