Crell / Serde

Robust Serde (serialization/deserialization) library for PHP 8.
Other
299 stars 14 forks source link

Only use the constructor param default if the parameter is promoted #72

Closed Crell closed 8 hours ago

Crell commented 1 month ago

Detailed description

Currently, Serde tries to use the default value from a matching-name constructor parameter as a default for a property. That's fine if it's a promoted property. If there is a constructor parameter that matches the name of a separately defined property, however, and they don't have the same type, type errors can occur.

Context

Ran into this in MiDy.

Possible implementation

Should be pretty easy to add an extra isPromoted check in Field.