8000 Merge branch 'PHP-8.3' into PHP-8.4 · php/php-src@e44c13c · GitHub
[go: up one dir, main page]

Skip to content

Commit e44c13c

Browse files
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-18695: float numbers zero fraction is now preserved in zend_ast_export() (#18699)
2 parents c441961 + 087f38f commit e44c13c

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PHP NEWS
1010
. Fixed bugs GH-17711 and GH-18022 (Infinite recursion on deprecated attribute
1111
evaluation) and GH-18464 (Recursion protection for deprecation constants not
1212
released on bailout). (DanielEScherzer and ilutov)
13+
. Fixed GH-18695 (zend_ast_export() - float number is not preserved).
14+
(Oleg Efimov)
1315

1416
- Date:
1517
. Fix leaks with multiple calls to DatePeriod iterator current(). (nielsdos)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Serialization of floats are correct
3+
--INI--
4+
zend.assertions=1
5+
--FILE--
6+
<?php
7+
try {
8+
assert(!is_float(0.0));
9+
} catch (AssertionError $e) {
10+
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
11+
}
12+
try {
13+
assert(!is_float(1.1));
14+
} catch (AssertionError $e) {
15+
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
16+
}
17+
try {
18+
assert(!is_float(1234.5678));
19+
} catch (AssertionError $e) {
20+
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
21+
}
22+
?>
23+
--EXPECT--
24+
assert(): assert(!is_float(0.0)) failed
25+
assert(): assert(!is_float(1.1)) failed
26+
assert(): assert(!is_float(1234.5678)) failed

Zend/zend_ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priorit
16081608
break;
16091609
case IS_DOUBLE:
16101610
smart_str_append_double(
1611-
str, Z_DVAL_P(zv), (int) EG(precision), /* zero_fraction */ false);
1611+
str, Z_DVAL_P(zv), (int) EG(precision), /* zero_fraction */ true);
16121612
break;
16131613
case IS_STRING:
16141614
smart_str_appendc(str, '\'');

0 commit comments

Comments
 (0)
0