]> granicus.if.org Git - php/commitdiff
Fixed bug #70982 (setStaticPropertyValue behaviors inconsistently with 5.6)
authorXinchen Hui <laruence@gmail.com>
Fri, 27 Nov 2015 03:32:38 +0000 (11:32 +0800)
committerXinchen Hui <laruence@gmail.com>
Fri, 27 Nov 2015 03:32:38 +0000 (11:32 +0800)
NEWS
ext/reflection/php_reflection.c
ext/reflection/tests/bug70982.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index bd6f283b1f7329d3ac98ad1667f22215aed036e9..635ba29b736beaf85535d6f9841c3b7b1d9dacaa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,10 @@ PHP                                                                        NEWS
 - Phpdbg:
   . Fixed stderr being written to stdout. (Bob)
 
+- Reflection:
+  . Fixed bug #70982 (setStaticPropertyValue behaviors inconsistently with
+    5.6). (Laruence)
+
 - Standard:
   . Fixed bug #70960 (ReflectionFunction for array_unique returns wrong number
     of parameters). (Laruence)
index faced0572c9c11e39212a92ec7c6c9895c96980b..72df8b590170916a0cb4c681faa69077258e0a09 100644 (file)
@@ -3858,6 +3858,7 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue)
                                "Class %s does not have a property named %s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
                return;
        }
+       ZVAL_DEREF(variable_ptr);
        zval_ptr_dtor(variable_ptr);
        ZVAL_COPY(variable_ptr, value);
 }
diff --git a/ext/reflection/tests/bug70982.phpt b/ext/reflection/tests/bug70982.phpt
new file mode 100644 (file)
index 0000000..3d6aadd
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug #70982 (setStaticPropertyValue behaviors inconsistently with 5.6)
+--FILE--
+<?php
+class Foo {
+       static $abc;
+       function __construct()
+       {
+               var_dump(static::$abc);
+       }
+}
+
+class Bar extends Foo {
+
+}
+
+$rf = new ReflectionClass('Bar');
+$rf->setStaticPropertyValue('abc', 'hi');
+$foo = $rf->newInstance();
+?>
+--EXPECT--
+string(2) "hi"