]> granicus.if.org Git - php/commitdiff
Fixed bug #78648
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 8 Oct 2019 13:39:22 +0000 (15:39 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 8 Oct 2019 13:39:22 +0000 (15:39 +0200)
Zend/tests/type_declarations/typed_properties_016.phpt
Zend/zend_compile.c

index e2b98a096dbcf8704dd7042f91d4233722bf240a..3be4d02b7ffa920b307edaea6628900b60a561a5 100644 (file)
@@ -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) {
+  }
+}
index e93855cc452698623dddc9638e9d27a3817c1932..255b89d95f065896c9dd916f1f55148643c3a868 100644 (file)
@@ -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",