Skip to content

Commit 9004102

Browse files
committed
Fixed bug #78648
1 parent ad3ddf4 commit 9004102

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Zend/tests/type_declarations/typed_properties_016.phpt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,22 @@ class Foo {
1010
public bool $bool = false;
1111
public iterable $iter = [];
1212
}
13-
echo "ok\n";
13+
var_dump(new Foo);
1414
?>
1515
--EXPECT--
16-
ok
16+
object(Foo)#1 (6) {
17+
["int"]=>
18+
int(1)
19+
["flt"]=>
20+
float(2.2)
21+
["flt2"]=>
22+
float(2)
23+
["arr"]=>
24+
array(0) {
25+
}
26+
["bool"]=>
27+
bool(false)
28+
["iter"]=>
29+
array(0) {
30+
}
31+
}

Zend/zend_compile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6121,6 +6121,7 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t flags) /
61216121
zend_error_noreturn(E_COMPILE_ERROR,
61226122
"Default value for property of type float can only be float or int");
61236123
}
6124+
convert_to_double(&value_zv);
61246125
} else if (!ZEND_SAME_FAKE_TYPE(ZEND_TYPE_CODE(type), Z_TYPE(value_zv))) {
61256126
zend_error_noreturn(E_COMPILE_ERROR,
61266127
"Default value for property of type %s can only be %s",

0 commit comments

Comments
 (0)