com php-src: Fixed bug #78648: Zend/tests/type_declarations/t yped_properties_016.phpt Zend/zend_compile.c
| From: | Nikita Popov | Date: | Tue, 08 Oct 2019 13:39:22 +0000 |
| Subject: | com php-src: Fixed bug #78648: Zend/tests/type_declarations/t yped_properties_016.phpt Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108804@lists.php.net to get a copy of this message | ||
Commit: 9004102b99be4d3811d69ad61149dc2959579e0a
Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 8 Oct 2019 15:39:22 +0200
Parents: ad3ddf46f9f5c97c43f04612bb448fcd109e2926
Branches: PHP-7.4
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9004102b99be4d3811d69ad61149dc2959579e0a
Log:
Fixed bug #78648
Bugs:
https://bugs.php.net/78648
Changed paths:
M Zend/tests/type_declarations/typed_properties_016.phpt
M Zend/zend_compile.c
Diff:
diff --git a/Zend/tests/type_declarations/typed_properties_016.phpt
b/Zend/tests/type_declarations/typed_properties_016.phpt
index e2b98a096db..3be4d02b7ff 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 e93855cc452..255b89d95f0 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",