Closed
Description
Symfony version(s) affected
6.1
Description
When i want to collect denomalization errors i got and a TypeError instead
How to reproduce
class SerializerIssueReport extends TestCase
{
public function testCollectErrorsOnEnum()
{
$serializer = new Serializer(
[
new BackedEnumNormalizer(),
new ObjectNormalizer(),
],
['json' => new JsonEncoder()]
);
$serializer->deserialize('{"test": "invalid"}', DummyObject::class, 'json', [
DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true
]);
$this->expectException(PartialDenormalizationException::class);
}
}
class DummyObject {
public function __construct(
public TestEnum $test,
)
{
}
}
enum TestEnum: String
{
case Test = "test";
}
Result: TypeError: DummyObject::__construct(): Argument #1 ($test) must be of type TestEnum, string given
Possible Solution
No response
Additional Context
No response