Skip to content

Commit 9792a6b

Browse files
committed
fix: $fraction type
NumberFormatter::setAttribute(): Passing null to parameter #2 ($value) of type int|float is deprecated
1 parent d42da43 commit 9792a6b

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

system/Helpers/number_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function number_to_amount($num, int $precision = 0, ?string $locale = null)
116116
* @param string $locale
117117
* @param int $fraction
118118
*/
119-
function number_to_currency(float $num, string $currency, ?string $locale = null, ?int $fraction = null): string
119+
function number_to_currency(float $num, string $currency, ?string $locale = null, int $fraction = 0): string
120120
{
121121
return format_number($num, 1, $locale, [
122122
'type' => NumberFormatter::CURRENCY,

tests/system/Helpers/NumberHelperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public function testQuadrillions()
126126
*/
127127
public function testCurrencyCurrentLocale()
128128
{
129+
$this->assertSame('$1,235', number_to_currency(1234.56, 'USD', 'en_US'));
129130
$this->assertSame('$1,234.56', number_to_currency(1234.56, 'USD', 'en_US', 2));
130131
$this->assertSame('£1,234.56', number_to_currency(1234.56, 'GBP', 'en_GB', 2));
131132
$this->assertSame("1.234,56\u{a0}RSD", number_to_currency(1234.56, 'RSD', 'sr_RS', 2));

0 commit comments

Comments
 (0)