[php-src] PR #22131: ext/Intl: Return PHP_INT_MIN as int from MessageFormatter::parse() on 64-bit
| From: | LamentXU123 | Date: | Fri, 22 May 2026 18:35:06 +0000 |
| Subject: | [php-src] PR #22131: ext/Intl: Return PHP_INT_MIN as int from MessageFormatter::parse() on 64-bit | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36203@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22131
Author: LamentXU123
Cleaning up.
-ZEND_LONG_MAX does not equals to ZEND_LONG_MIN, because
signed integer ranges are not symmetric
in 64-bit
```
-ZEND_LONG_MAX = -9223372036854775807
ZEND_LONG_MIN = -9223372036854775808
```
This makes -9,223,372,036,854,775,808 in MessageFormatterbe degraded into float, but it could be a
integer.
```php
<?php
$fmt = new MessageFormatter('en_US', '{0,number,integer}');
$parsed = $fmt->parse('-9,223,372,036,854,775,808');
var_dump($parsed);
$parsed = MessageFormatter::parseMessage('en_US', '{0,number,integer}',
'-9,223,372,036,854,775,808');
var_dump($parsed);
?>
```
result in
```php
array(1) {
[0]=>
float(-9.223372036854776E+18)
}
array(1) {
[0]=>
float(-9.223372036854776E+18)
}
```
But it should be
```
array(1) {
[0]=>
int(-9223372036854775808)
}
array(1) {
[0]=>
int(-9223372036854775808)
}
```
[Reproduce](https://onlinephp.io?s=s7EvyCjg5eLlUknLLVGwVchLLVfwTS0uTkxPdcsvyk0sKUkt0lBPzYsPDVbXUVCvNtDJK81NSi3SycwrSU1PLapV17QGai5ILCpOTQHqBxmjawfmaqjrWuoYGRnrGJsb6RgYm-lYmJromJub6lgYWIB1lSUWxaeU5hZoQLWDxJDNQneHlRVYCiqM31VAUbJst7cDAA%2C%2C&v=8.5.6%2C8.4.21)
This is really a super super edge case. I don't even sure we should treat this as a bug fix or
a refactor at this point. It really do come into my mind when I am looking at this code that I
don't even think we need any NEWS or UPGRADING entry for this little fix. No similar bugs in
the code base.