mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
MFH: Fix issue reported by Roman Borschel.
This commit is contained in:
parent
99152e8f58
commit
03e48b1535
3 changed files with 61 additions and 2 deletions
2
NEWS
2
NEWS
|
@ -29,6 +29,8 @@ PHP NEWS
|
|||
update). (Matteo)
|
||||
- Fixed bug #42362 (HTTP status codes 204 and 304 should not be gzipped).
|
||||
(Scott, Edward Z. Yang)
|
||||
- Fixed an issue with ReflectionProperty::setAccessible().
|
||||
(Sebastian, Roman Borschel)
|
||||
|
||||
|
||||
24 Mar 2009, PHP 5.3.0 RC 1
|
||||
|
|
|
@ -4491,7 +4491,7 @@ ZEND_METHOD(reflection_property, getValue)
|
|||
return;
|
||||
}
|
||||
zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name);
|
||||
member_p = zend_read_property(Z_OBJCE_P(object), object, prop_name, strlen(prop_name), 1 TSRMLS_CC);
|
||||
member_p = zend_read_property(ref->ce, object, prop_name, strlen(prop_name), 1 TSRMLS_CC);
|
||||
*return_value= *member_p;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
|
@ -4569,7 +4569,7 @@ ZEND_METHOD(reflection_property, setValue)
|
|||
return;
|
||||
}
|
||||
zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name);
|
||||
zend_update_property(Z_OBJCE_P(object), object, prop_name, strlen(prop_name), value TSRMLS_CC);
|
||||
zend_update_property(ref->ce, object, prop_name, strlen(prop_name), value TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -9,6 +9,8 @@ class A {
|
|||
private static $privateStatic = 'd';
|
||||
}
|
||||
|
||||
class B extends A {}
|
||||
|
||||
$a = new A;
|
||||
$protected = new ReflectionProperty($a, 'protected');
|
||||
$protectedStatic = new ReflectionProperty('A', 'protectedStatic');
|
||||
|
@ -66,6 +68,52 @@ var_dump($protected->getValue($a));
|
|||
var_dump($protectedStatic->getValue());
|
||||
var_dump($private->getValue($a));
|
||||
var_dump($privateStatic->getValue());
|
||||
|
||||
$a = new A;
|
||||
$b = new B;
|
||||
$protected = new ReflectionProperty($b, 'protected');
|
||||
$protectedStatic = new ReflectionProperty('B', 'protectedStatic');
|
||||
$private = new ReflectionProperty($a, 'private');
|
||||
|
||||
try {
|
||||
var_dump($protected->getValue($b));
|
||||
}
|
||||
|
||||
catch (ReflectionException $e) {
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump($protectedStatic->getValue());
|
||||
}
|
||||
|
||||
catch (ReflectionException $e) {
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump($private->getValue($b));
|
||||
}
|
||||
|
||||
catch (ReflectionException $e) {
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
|
||||
$protected->setAccessible(TRUE);
|
||||
$protectedStatic->setAccessible(TRUE);
|
||||
$private->setAccessible(TRUE);
|
||||
|
||||
var_dump($protected->getValue($b));
|
||||
var_dump($protectedStatic->getValue());
|
||||
var_dump($private->getValue($b));
|
||||
|
||||
$protected->setValue($b, 'e');
|
||||
$protectedStatic->setValue('f');
|
||||
$private->setValue($b, 'g');
|
||||
|
||||
var_dump($protected->getValue($b));
|
||||
var_dump($protectedStatic->getValue());
|
||||
var_dump($private->getValue($b));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(44) "Cannot access non-public member A::protected"
|
||||
|
@ -80,3 +128,12 @@ string(1) "e"
|
|||
string(1) "f"
|
||||
string(1) "g"
|
||||
string(1) "h"
|
||||
string(44) "Cannot access non-public member B::protected"
|
||||
string(50) "Cannot access non-public member B::protectedStatic"
|
||||
string(42) "Cannot access non-public member A::private"
|
||||
string(1) "a"
|
||||
string(1) "f"
|
||||
string(1) "c"
|
||||
string(1) "e"
|
||||
string(1) "f"
|
||||
string(1) "g"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue