com php-src: fix trait inheritance: Zend/tests/type_declarati ons/typed_properties_026.phpt Zend/zend_inherit ance.c

From: Date: Fri, 11 Mar 2016 10:08:53 +0000
Subject: com php-src: fix trait inheritance: Zend/tests/type_declarati ons/typed_properties_026.phpt Zend/zend_inherit ance.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95687@lists.php.net to get a copy of this message
Commit: 7ed980ea7b49c41dc2d7331f686df806110fc6d9 Author: Joe Watkins <krakjoe@php.net> Fri, 11 Mar 2016 10:08:53 +0000 Parents: 2fde206041392f75df8f9e7eeeb92d0dfe2e9c48 Branches: typed_ref_properties Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7ed980ea7b49c41dc2d7331f686df806110fc6d9 Log: fix trait inheritance Changed paths: A 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 new file mode 100644 index 0000000..62e0d8b --- /dev/null +++ b/Zend/tests/type_declarations/typed_properties_026.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test typed properties inherit traits with typed properties +--FILE-- +<?php +trait Foo{ + private int $baz; +} + +class Baz{ + use Foo; + + function get(){ + return $this->baz; + } +} + +var_dump((new Baz)->get()); +--EXPECTF-- +Fatal error: Typed property Baz::$baz must be integer, null used in %s on line 6 + + + + + + diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index c5d1eeb..da70ce4 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1633,9 +1633,10 @@ static void zend_do_traits_property_binding(zend_class_entry *ce) /* {{{ */ if (Z_REFCOUNTED_P(prop_value)) Z_ADDREF_P(prop_value); doc_comment = property_info->doc_comment ? zend_string_copy(property_info->doc_comment) : NULL; - zend_declare_property_ex(ce, prop_name, - prop_value, flags, - doc_comment); + if (property_info->type) { + 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); + zend_string_release(prop_name); } ZEND_HASH_FOREACH_END(); }

« previous php.cvs (#95687) next »