From: Nikita Popov Date: Tue, 8 Oct 2019 13:39:22 +0000 (+0200) Subject: Fixed bug #78648 X-Git-Tag: php-7.4.0RC4~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9004102b99be4d3811d69ad61149dc2959579e0a;p=php Fixed bug #78648 --- diff --git a/Zend/tests/type_declarations/typed_properties_016.phpt b/Zend/tests/type_declarations/typed_properties_016.phpt index e2b98a096d..3be4d02b7f 100644 --- a/Zend/tests/type_declarations/typed_properties_016.phpt +++ b/Zend/tests/type_declarations/typed_properties_016.phpt @@ -10,7 +10,22 @@ class Foo { public bool $bool = false; public iterable $iter = []; } -echo "ok\n"; +var_dump(new Foo); ?> --EXPECT-- -ok +object(Foo)#1 (6) { + ["int"]=> + int(1) + ["flt"]=> + float(2.2) + ["flt2"]=> + float(2) + ["arr"]=> + array(0) { + } + ["bool"]=> + bool(false) + ["iter"]=> + array(0) { + } +} diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index e93855cc45..255b89d95f 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6121,6 +6121,7 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t flags) / zend_error_noreturn(E_COMPILE_ERROR, "Default value for property of type float can only be float or int"); } + convert_to_double(&value_zv); } else if (!ZEND_SAME_FAKE_TYPE(ZEND_TYPE_CODE(type), Z_TYPE(value_zv))) { zend_error_noreturn(E_COMPILE_ERROR, "Default value for property of type %s can only be %s",