From: Nikita Popov Date: Tue, 15 Jan 2019 08:53:37 +0000 (+0100) Subject: Fix handling of UNDEF properties in compound assign X-Git-Tag: php-7.4.0alpha1~1221 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61d00c0c55ebbc2fa59af35befd2f61a80571675;p=php Fix handling of UNDEF properties in compound assign Restore NULLing of UNDEF values in get_property_ptr_ptr for the BP_VAR_R and BP_VAR_RW cases. --- diff --git a/Zend/tests/type_declarations/typed_properties_103.phpt b/Zend/tests/type_declarations/typed_properties_103.phpt new file mode 100644 index 0000000000..5c0fc85a99 --- /dev/null +++ b/Zend/tests/type_declarations/typed_properties_103.phpt @@ -0,0 +1,22 @@ +--TEST-- +Handling of UNDEF property in compound assign +--FILE-- +a = 1; + unset($x->a); + $x->a += 2; + var_dump($x); +} +foo(); +?> +--EXPECTF-- +Notice: Undefined property: C::$a in %s on line %d +object(C)#1 (1) { + ["a"]=> + int(2) +} diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index e91202669b..e1e1ff6284 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1018,6 +1018,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int typ if (EXPECTED(!zobj->ce->__get) || UNEXPECTED((*zend_get_property_guard(zobj, name)) & IN_GET)) { if (UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) { + ZVAL_NULL(retval); zend_error(E_NOTICE, "Undefined property: %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name)); } } else {