diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-08 15:39:22 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-08 15:39:22 +0200 |
commit | 9004102b99be4d3811d69ad61149dc2959579e0a (patch) | |
tree | 2163c535c337257dd9e334ab1aa448518b9cf0e3 | |
parent | ad3ddf46f9f5c97c43f04612bb448fcd109e2926 (diff) | |
download | php-git-9004102b99be4d3811d69ad61149dc2959579e0a.tar.gz |
Fixed bug #78648
-rw-r--r-- | Zend/tests/type_declarations/typed_properties_016.phpt | 19 | ||||
-rw-r--r-- | Zend/zend_compile.c | 1 |
2 files changed, 18 insertions, 2 deletions
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", |