--- a/src/Illuminate/Support/Number.php 2026-09-09 16:32:41 +++ b/src/Illuminate/Support/Number.php 2026-09-09 16:32:20 @@ -37,6 +37,12 @@ { static::ensureIntlExtensionIsInstalled(); + if (! class_exists('NumberFormatter')) { + $digits = $maxPrecision ?? $precision; + + return number_format($number, $digits ?? 0, '.', ','); + } + $formatter = new NumberFormatter($locale ?? static::$locale, NumberFormatter::DECIMAL); if (! is_null($maxPrecision)) { @@ -47,7 +53,6 @@ return $formatter->format($number); } - /** * Parse the given string according to the specified format type. * @@ -186,15 +191,24 @@ { static::ensureIntlExtensionIsInstalled(); + if (! class_exists('NumberFormatter')) { + $symbol = trim($in); + + return ($symbol !== '' ? $symbol.' ' : '').number_format($number, $precision ?? 2, '.', ','); + } + $formatter = new NumberFormatter($locale ?? static::$locale, NumberFormatter::CURRENCY); if (! is_null($precision)) { $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $precision); } - return $formatter->formatCurrency($number, ! empty($in) ? $in : static::$currency); - } + if ($in !== '') { + $formatter->setTextAttribute(NumberFormatter::CURRENCY_CODE, $in); + } + return $formatter->formatCurrency($number, $in); + } /** * Convert the given number to its file size equivalent. * @@ -447,10 +461,5 @@ */ protected static function ensureIntlExtensionIsInstalled() { - if (! extension_loaded('intl')) { - $method = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']; - - throw new RuntimeException('The "intl" PHP extension is required to use the ['.$method.'] method.'); - } - } -} + // intl extension optional: a native number_format fallback is used when unavailable. + }}