moneyphp / money

PHP implementation of Fowler's Money pattern.
http://moneyphp.org
MIT License
4.6k stars 440 forks source link

Money values of '0' give an assertion error in decimal formats #655

Closed Venorcis closed 3 years ago

Venorcis commented 3 years ago

https://github.com/moneyphp/money/blob/df7234fcb412d337b309e1b20d00f977614f82d5/src/Formatter/IntlMoneyFormatter.php#L61

I believe this empty check is incorrect, because it will trigger an AssertionError on the string '0', which could be a perfectly fine result (e.g. in Polish decimal localisation). I'd suggest removing these assertions altogether; they occur in multiple formatters!

UlrichEckhardt commented 3 years ago

PHP at its finest again:

php > var_dump(empty('0'));
bool(true)

Should that be assert($formatted !== ''); instead?