(Nikita)
. Fixed bug #79852 (count(DOMNodeList) doesn't match
count(IteratorIterator(DOMNodeList))). (Nikita)
+ . Fixed bug #79867 (Promoted untyped properties should get null default
+ value). (Nikita)
09 Jul 2020, PHP 8.0.0alpha2
--- /dev/null
+--TEST--
+Bug #79867: Promoted untyped properties should get null default value
+--FILE--
+<?php
+
+class A {
+ public function __construct(
+ public $untyped = 1,
+ public int $typed = 2,
+ ) {}
+}
+
+class B extends A {
+ public function __construct() {
+ // Missing parent::__construct() call,
+ // properties will not be initialized.
+ }
+}
+
+var_dump(new B);
+
+?>
+--EXPECT--
+object(B)#1 (1) {
+ ["untyped"]=>
+ NULL
+ ["typed"]=>
+ uninitialized(int)
+}
ZSTR_VAL(scope->name), ZSTR_VAL(name), ZSTR_VAL(str));
}
- /* Always use uninitialized as the default. */
- zval default_value;
- ZVAL_UNDEF(&default_value);
-
/* Recompile the type, as it has different memory management requirements. */
zend_type type = ZEND_TYPE_INIT_NONE(0);
if (type_ast) {
type = zend_compile_typename(type_ast, /* force_allow_null */ 0, /* use_arena */ 1);
}
+ /* Don't give the property an explicit default value. For typed properties this means
+ * uninitialized, for untyped properties it means an implicit null default value. */
+ zval default_value;
+ if (ZEND_TYPE_IS_SET(type)) {
+ ZVAL_UNDEF(&default_value);
+ } else {
+ ZVAL_NULL(&default_value);
+ }
+
zend_string *doc_comment =
doc_comment_ast ? zend_string_copy(zend_ast_get_str(doc_comment_ast)) : NULL;
zend_property_info *prop = zend_declare_typed_property(