com php-src: make consistent with RFC (nullables): Zend/tests/t ype_declarations/typed_properties_047.phpt Zend
/tests/type_declarations/typed_properties_048.php t Zend/zend_object_handlers.c

From: Date: Tue, 07 Jun 2016 06:50:28 +0000
Subject: com php-src: make consistent with RFC (nullables): Zend/tests/t ype_declarations/typed_properties_047.phpt Zend
/tests/type_declarations/typed_properties_048.php t Zend/zend_object_handlers.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95494@lists.php.net to get a copy of this message
Commit: 71cda1bf485a9ad2e0b50a6720c3d3bb9956a7ee Author: Joe Watkins <krakjoe@php.net> Tue, 7 Jun 2016 07:50:28 +0100 Parents: de84f5082a2da6944726e2f7cb3ba73b7f568021 Branches: typed_ref_properties Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=71cda1bf485a9ad2e0b50a6720c3d3bb9956a7ee Log: make consistent with RFC (nullables) Changed paths: M Zend/tests/type_declarations/typed_properties_047.phpt M Zend/tests/type_declarations/typed_properties_048.phpt M Zend/zend_object_handlers.c Diff: diff --git a/Zend/tests/type_declarations/typed_properties_047.phpt b/Zend/tests/type_declarations/typed_properties_047.phpt index d3bdc23..fdd5473 100644 --- a/Zend/tests/type_declarations/typed_properties_047.phpt +++ b/Zend/tests/type_declarations/typed_properties_047.phpt @@ -56,7 +56,5 @@ object(Foo)#1 (1) { NULL int(5) NULL - -Notice: Undefined property: Foo::$foo in %styped_properties_047.php on line 38 -NULL +Typed property Foo::$foo must not be accessed before initialization Typed property Foo::$foo must be integer, string used diff --git a/Zend/tests/type_declarations/typed_properties_048.phpt b/Zend/tests/type_declarations/typed_properties_048.phpt index 0bdb0f6..59ca7e3 100644 --- a/Zend/tests/type_declarations/typed_properties_048.phpt +++ b/Zend/tests/type_declarations/typed_properties_048.phpt @@ -56,7 +56,5 @@ object(Foo)#1 (1) { NULL int(5) NULL - -Notice: Undefined property: Foo::$foo in %styped_properties_048.php on line 38 -NULL +Typed property Foo::$foo must not be accessed before initialization Typed property Foo::$foo must be integer, string used diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 3639a9d..227871c 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -694,12 +694,13 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_ } } if ((type != BP_VAR_IS)) { - if (UNEXPECTED(prop_info = zend_object_fetch_property_type_info(Z_OBJCE_P(object), Z_STR_P(member), cache_slot)) - && UNEXPECTED(!prop_info->allow_null)) { - zend_throw_exception_ex(zend_ce_type_error, prop_info->type, + if (UNEXPECTED(prop_info = zend_object_fetch_property_type_info(Z_OBJCE_P(object), Z_STR_P(member), cache_slot))) { + if (UNEXPECTED(!prop_info->allow_null || Z_TYPE_P(retval) == IS_UNDEF)) { + zend_throw_exception_ex(zend_ce_type_error, prop_info->type, "Typed property %s::$%s must not be accessed before initialization", - ZSTR_VAL(prop_info->ce->name), - Z_STRVAL_P(member)); + ZSTR_VAL(prop_info->ce->name), + Z_STRVAL_P(member)); + } } else { zend_error(E_NOTICE,"Undefined property: %s::$%s", ZSTR_VAL(zobj->ce->name), Z_STRVAL_P(member)); }

« previous php.cvs (#95494) next »