Skip to content

Fix NumberFormatter ignoring an explicit 0 decimals - #179

Open
CasperBE wants to merge 1 commit into
num-num:masterfrom
CasperBE:fix-numberformatter
Open

Fix NumberFormatter ignoring an explicit 0 decimals#179
CasperBE wants to merge 1 commit into
num-num:masterfrom
CasperBE:fix-numberformatter

Conversation

@CasperBE

Copy link
Copy Markdown
Contributor

The check for the optional $decimals argument used a loose comparison, so an explicit 0 was treated the same as null and fell back to auto-detecting the decimals present in the input. NumberFormatter::format(12.345, 0) returned '12.345' instead of '12'.

The NumberFormatterTest was never executed: it sits at the root of tests/, while phpunit.xml only registered the tests/Write and tests/Read directories. Added a 'unit' testsuite covering the root so the new cases actually run.

The check for the optional $decimals argument used a loose comparison,
so an explicit 0 was treated the same as null and fell back to
auto-detecting the decimals present in the input. NumberFormatter::format(12.345, 0)
returned '12.345' instead of '12'.

The NumberFormatterTest was never executed: it sits at the root of
tests/, while phpunit.xml only registered the tests/Write and tests/Read
directories. Added a 'unit' testsuite covering the root so the new
cases actually run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant