schmittjoh / serializer

Library for (de-)serializing data of any complexity (supports JSON, and XML)
http://jmsyst.com/libs/serializer
MIT License
2.32k stars 586 forks source link

serialize() throws error when object has member of type "float|int|null" #1562

Open captain-igloo opened 1 day ago

captain-igloo commented 1 day ago
Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no

The following code throws an error under version 3.31.0 but not under 3.30.0:

class Foo
{
    public float|int|null $a = 99;
}

$serializer = SerializerBuilder::create()->build();
$serializer->serialize(new Foo(), 'json');

The error is:

In Parser.php line 30:                                                                                       
JMS\Serializer\Type\Parser::parse(): Return value must be of type array, null returned
kargpfen commented 1 day ago

I have the same problem 🙁

scyzoryck commented 1 day ago

Thanks! I will take a look in the evening on this issue.

KevinMarques commented 6 hours ago

Same here. Thank you for taking a look ;)