Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6b95875

Browse files
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-18695: float numbers zero fraction is now preserved in zend_ast_export() (#18699)
2 parents 615b980 + e44c13c commit 6b95875

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
@@ -53,6 +53,8 @@ PHP NEWS
5353
evaluation) and GH-18464 (Recursion protection for deprecation constants not
5454
released on bailout). (DanielEScherzer and ilutov)
5555
. Fixed AST printing for immediately invoked Closure. (Dmitrii Derepko)
56+
. Fixed GH-18695 (zend_ast_export() - float number is not preserved).
57+
(Oleg Efimov)
5658

5759
- Curl:
5860
. Added curl_multi_get_handles(). (timwolla)
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
@@ -1820,7 +1820,7 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priorit
18201820
break;
18211821
case IS_DOUBLE:
18221822
smart_str_append_double(
1823-
str, Z_DVAL_P(zv), (int) EG(precision), /* zero_fraction */ false);
1823+
str, Z_DVAL_P(zv), (int) EG(precision), /* zero_fraction */ true);
18241824
break;
18251825
case IS_STRING:
18261826
smart_str_appendc(str, '\'');

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /