]> granicus.if.org Git - php/commitdiff
Fix handling of UNDEF properties in compound assign
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 15 Jan 2019 08:53:37 +0000 (09:53 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 15 Jan 2019 08:55:55 +0000 (09:55 +0100)
Restore NULLing of UNDEF values in get_property_ptr_ptr for the
BP_VAR_R and BP_VAR_RW cases.

Zend/tests/type_declarations/typed_properties_103.phpt [new file with mode: 0644]
Zend/zend_object_handlers.c

diff --git a/Zend/tests/type_declarations/typed_properties_103.phpt b/Zend/tests/type_declarations/typed_properties_103.phpt
new file mode 100644 (file)
index 0000000..5c0fc85
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Handling of UNDEF property in compound assign 
+--FILE--
+<?php
+class C {
+    public $a = 0;
+}
+function foo() {
+    $x = new C;
+    $x->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)
+}
index e91202669be56367e81097ed939db776e4fd49b7..e1e1ff62844336cb67d917b298b440fbaa42a406 100644 (file)
@@ -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 {