com php-src: typed properties need to be undef initial value: Zend/tests/type_declarations/typed_properties_026 .phpt Zend/zend_inheritance.c

From: Date: Fri, 11 Mar 2016 12:28:07 +0000
Subject: com php-src: typed properties need to be undef initial value: Zend/tests/type_declarations/typed_properties_026 .phpt Zend/zend_inheritance.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95683@lists.php.net to get a copy of this message
Commit: db9e5743519756080278646ab0d8d055c86a0ae4 Author: Joe Watkins <krakjoe@php.net> Fri, 11 Mar 2016 12:28:07 +0000 Parents: 113dc9df1a0de610b8a84db1397195a426c61d23 Branches: typed_ref_properties Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=db9e5743519756080278646ab0d8d055c86a0ae4 Log: typed properties need to be undef initial value Changed paths: M Zend/tests/type_declarations/typed_properties_026.phpt M Zend/zend_inheritance.c Diff: diff --git a/Zend/tests/type_declarations/typed_properties_026.phpt b/Zend/tests/type_declarations/typed_properties_026.phpt index 62e0d8b..250ea06 100644 --- a/Zend/tests/type_declarations/typed_properties_026.phpt +++ b/Zend/tests/type_declarations/typed_properties_026.phpt @@ -16,7 +16,11 @@ class Baz{ var_dump((new Baz)->get()); --EXPECTF-- -Fatal error: Typed property Baz::$baz must be integer, null used in %s on line 6 +Fatal error: Uncaught TypeError: Typed property Baz::$baz must not be accessed before initialization in %s:10 +Stack trace: +#0 %s(14): Baz->get() +#1 {main} + thrown in %s on line 10 diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 5086720..bc11a0a 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1634,6 +1634,9 @@ static void zend_do_traits_property_binding(zend_class_entry *ce) /* {{{ */ doc_comment = property_info->doc_comment ? zend_string_copy(property_info->doc_comment) : NULL; if (property_info->type) { + if (Z_TYPE_P(prop_value) == IS_NULL) { + ZVAL_UNDEF(prop_value); + } zend_declare_typed_property(ce, prop_name, prop_value, flags, doc_comment, property_info->type, property_info->type_name); } else { zend_declare_property_ex(ce, prop_name, prop_value, flags, doc_comment);

« previous php.cvs (#95683) next »