transit-php
transit-php copied to clipboard
Noisier warning if JSON_PRESERVE_ZERO_FRACTION not available
If JSON_PRESERVE_ZERO_FRACTION isn't defined, then this library converts any whole-number float value to an integer. This can cause some hard-to-find bugs and it would be better if this script complained more loudly.
I think this package should have a check for if(!defined('JSON_PRESERVE_ZERO_FRACTION'))
and throw an E_USER_WARNING or exception. It could either do this all the time, or it could do it only if float / whole-number-float values are included in a data payload.
Generally speaking I would advise against using this package if JSON_PRESERVE_ZERO_FRACTION wasn't available. Probably, I would recommend that the user of the package upgrades.
What do you think?
This is where the error manifests itself https://github.com/nette/utils/blob/master/src/Utils/Json.php#L34
Nice catch! Would you like to send PR, please?