smartemailing / types

Missing data types for PHP. Highly extendable.
Other
89 stars 12 forks source link

Missing JsonSerializable interface #129

Open asgraf opened 1 year ago

asgraf commented 1 year ago

What i did:

$data = [
    'quantity' => Quantity::from(5)
];
debug(json_encode($data));

Expected result:

{
   "quantity": 5
}

Actual result:

{
   "quantity": {}
}
asgraf commented 1 year ago

I think this could be easily implemented at level of ExtractableTraits

mstrouhal commented 12 months ago

Thank you for this feature request, it is very reasonable. Despite it can not be implemented on level of Extractable traits, as they do not have access to $value property inside object instances, it is possible to implement this feature in a slightly different way. I am working on it.

mstrouhal commented 12 months ago

https://github.com/smartemailing/types/pull/130/files