-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Description
Description
The following code:
<?php
if ( ! in_array( 'skr', IntlCalendar::getAvailableLocales(), true ) ) {
echo 'locale is not available';
}Resulted in this output:
locale is not available
I expected the locale to be available, since skr is a valid ISO 639-3 language code for the Saraiki language, spoken by 20+ million people. Should it be added to the list of supported languages?
This issue may not be new, but after recent changes to NumberFormatter in PHP 8.4, it will now return a ValueError if the locale is invalid.
Code like below can consequently generate fatal errors now:
<?php
$formatter = new NumberFormatter( 'skr', 14 );
$formatter->setAttribute( 6, 1 );
echo $formatter->format( '123456' );Resulted in this output in PHP 8.4:
PHP Fatal error: Uncaught ValueError: NumberFormatter::__construct(): Argument #1 ($locale) "skr" is invalid in /test.php:2
Stack trace:
#0 test.php(2): NumberFormatter->__construct('skr', 14)
#1 {main}
thrown in /test.php on line 2
While in PHP 8.3:
123.5K
PHP Version
PHP 8.4.6 (cli) (built: Apr 8 2025 19:55:31) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.6, Copyright (c) Zend Technologies
with Zend OPcache v8.4.6, Copyright (c), by Zend Technologies
Operating System
No response