The current behavior when formatting number is a bit inconsistent when the minimum number of fraction digits is set.
Let's assume we have minimum number of fraction digits set to 3. The current fomating would do that:
With the suggested changes the
50 should result in
50.000. There is actually a test covering exact that case, unfortunately it doesn't fail at the moment, as the
assertEquals in the PHPUnit version we are using returns true when comparing
assertSame would actually fail. In newer PHPUnit versions the
assertEquals fails, too)
@sgiehl is there an issue for this? Looking at eg https://builds-artifacts.matomo.org/matomo-org/matomo/4.x-dev/38281/Dashboard_rowevolution.png it was maybe better before?
No there was no issue. I was preparing to update the PHPUnit version and this test suddenly started to fail as it return
50 and not
50.000 as defined in the test:
The format function takes two parameters for
maximumFractionDigits. Imho it is logically incorrect to return no faction digits if minimum and maximum are set to
3 but they would be zero filled :thinking:
Be just good to not regress UI. Do we have to update PHP Unit? Maybe we could wait with that unless we're after some particular feature? Of course it failing there shows there maybe is some issue which wasn't visible before but might still not be too important?
Do we otherwise need to maybe rename that parameter or add some doc to make the current behaviour more clear maybe?
The behavior is simply inconsistent. Imho we need to adjust the usage of the parameters. In the case you mentioned above it imho would make more sense to set minimum fraction digits to 0. So it would also return
0 instead of
0.0.0, but also
5.23 instead of
In the case you mentioned above it imho would make more sense to set minimum fraction digits to 0. So it would also return 0 instead of 0.0.0, but also 5.23 instead of 5.230.
👍 probably need to do this in most places to keep existing behaviour probably?
I searched through the code, but it looks like we didn't use the minimum fraction digits count anywhere else (besides in tests)
Tests seem to pass so looks good 👍