Browse Source

Merge branch 'PHP-7.0'

Conflicts:
	ext/reflection/php_reflection.c
pull/1894/merge
Nikita Popov 10 years ago
parent
commit
20560da118
  1. 13
      ext/reflection/php_reflection.c
  2. 2
      ext/reflection/tests/ReflectionProperty_getValue_error.phpt
  3. 36
      ext/reflection/tests/bug72174.phpt

13
ext/reflection/php_reflection.c

@ -5649,9 +5649,16 @@ ZEND_METHOD(reflection_property, getValue)
}
zend_unmangle_property_name_ex(ref->prop.name, &class_name, &prop_name, &prop_name_len);
member_p = zend_read_property(ref->ce, object, prop_name, prop_name_len, 1, &rv);
ZVAL_DEREF(member_p);
ZVAL_COPY(return_value, member_p);
member_p = zend_read_property(ref->ce, object, prop_name, prop_name_len, 0, &rv);
if (member_p != &rv) {
ZVAL_DEREF(member_p);
ZVAL_COPY(return_value, member_p);
} else {
if (Z_ISREF_P(member_p)) {
zend_unwrap_reference(member_p);
}
ZVAL_COPY_VALUE(return_value, member_p);
}
}
}
/* }}} */

2
ext/reflection/tests/ReflectionProperty_getValue_error.phpt

@ -78,4 +78,6 @@ Protected property:
Cannot access non-public member TestClass::prot
Instance without property:
Notice: Undefined property: AnotherClass::$pub2 in %s on line %d
NULL

36
ext/reflection/tests/bug72174.phpt

@ -0,0 +1,36 @@
--TEST--
Bug #72174: ReflectionProperty#getValue() causes __isset call
--FILE--
<?php
class Foo
{
private $bar;
public function __construct()
{
unset($this->bar);
}
public function __isset($name)
{
var_dump(__METHOD__);
return true;
}
public function __get($name)
{
var_dump(__METHOD__);
return $name;
}
}
$instance = new Foo();
$reflectionBar = (new ReflectionProperty(Foo::class, 'bar'));
$reflectionBar->setAccessible(true);
var_dump($reflectionBar->getValue($instance));
?>
--EXPECT--
string(10) "Foo::__get"
string(3) "bar"
Loading…
Cancel
Save