Skip to content

Fix GH-18695: float numbers zero fraction is now preserved in zend_ast_export() #18699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.3.23

- Core:
. Fixed GH-18695 (zend_ast_export() - float number is not preserved).
(Oleg Efimov)

- Date:
. Fix leaks with multiple calls to DatePeriod iterator current(). (nielsdos)

Expand Down
26 changes: 26 additions & 0 deletions Zend/tests/ast/ast_serialize_floats.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Serialization of floats are correct
--INI--
zend.assertions=1
--FILE--
<?php
try {
assert(!is_float(0.0));
} catch (AssertionError $e) {
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
}
try {
assert(!is_float(1.1));
} catch (AssertionError $e) {
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
}
try {
assert(!is_float(1234.5678));
} catch (AssertionError $e) {
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
}
?>
--EXPECT--
assert(): assert(!is_float(0.0)) failed
assert(): assert(!is_float(1.1)) failed
assert(): assert(!is_float(1234.5678)) failed
2 changes: 1 addition & 1 deletion Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priorit
break;
case IS_DOUBLE:
smart_str_append_double(
str, Z_DVAL_P(zv), (int) EG(precision), /* zero_fraction */ false);
str, Z_DVAL_P(zv), (int) EG(precision), /* zero_fraction */ true);
break;
case IS_STRING:
smart_str_appendc(str, '\'');
Expand Down
Loading