cvs: ZendEngine2 / zend_reflection_api.c
| From: | Marcus Boerger | Date: | Sun, 19 Sep 2004 11:54:08 +0000 |
| Subject: | cvs: ZendEngine2 / zend_reflection_api.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2994@lists.php.net to get a copy of this message | ||
helly Sun Sep 19 07:54:08 2004 EDT
Modified files:
/ZendEngine2 zend_reflection_api.c
Log:
Bugfix #30146 (ReflectionProperty->getValue() requires instance for static property)
http://cvs.php.net/diff.php/ZendEngine2/zend_reflection_api.c?r1=1.124&r2=1.125&ty=u
Index: ZendEngine2/zend_reflection_api.c
diff -u ZendEngine2/zend_reflection_api.c:1.124 ZendEngine2/zend_reflection_api.c:1.125
--- ZendEngine2/zend_reflection_api.c:1.124 Sun Sep 19 07:25:39 2004
+++ ZendEngine2/zend_reflection_api.c Sun Sep 19 07:54:08 2004
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_reflection_api.c,v 1.124 2004/09/19 11:25:39 helly Exp $ */
+/* $Id: zend_reflection_api.c,v 1.125 2004/09/19 11:54:08 helly Exp $ */
#include "zend.h"
#include "zend_API.h"
#include "zend_exceptions.h"
@@ -3024,7 +3024,7 @@
}
/* }}} */
-/* {{{ proto public mixed ReflectionProperty::getValue(stdclass object)
+/* {{{ proto public mixed ReflectionProperty::getValue([stdclass object])
Returns this property's value */
ZEND_METHOD(reflection_property, getValue)
{
@@ -3041,16 +3041,15 @@
/* Returns from this function */
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) {
- return;
- }
-
if ((ref->prop->flags & ZEND_ACC_STATIC)) {
- if (zend_hash_quick_find(Z_OBJCE_P(object)->static_members, ref->prop->name,
ref->prop->name_length + 1, ref->prop->h, (void **) &member) == FAILURE) {
+ if (zend_hash_quick_find(intern->ce->static_members, ref->prop->name,
ref->prop->name_length + 1, ref->prop->h, (void **) &member) == FAILURE) {
zend_error(E_ERROR, "Internal error: Could not find the property %s",
ref->prop->name);
/* Bails out */
}
} else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) {
+ return;
+ }
if (zend_hash_quick_find(Z_OBJPROP_P(object), ref->prop->name, ref->prop->name_length
+ 1, ref->prop->h, (void **) &member) == FAILURE) {
zend_error(E_ERROR, "Internal error: Could not find the property %s",
ref->prop->name);
/* Bails out */
@@ -3062,7 +3061,7 @@
}
/* }}} */
-/* {{{ proto public void ReflectionProperty::setValue(stdclass object, mixed value)
+/* {{{ proto public void ReflectionProperty::setValue([stdclass object,] mixed value)
Sets this property's value */
ZEND_METHOD(reflection_property, setValue)
{
@@ -3072,38 +3071,48 @@
zval *object;
zval *value;
int setter_done = 0;
+ zval *tmp;
+ HashTable *prop_table;
METHOD_NOTSTATIC;
GET_REFLECTION_OBJECT_PTR(ref);
- if (ref->prop->flags & ~ZEND_ACC_PUBLIC) {
+ if (ref->prop->flags & ~(ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)) {
_DO_THROW("Cannot access non-public member");
/* Returns from this function */
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oz", &object, &value) ==
FAILURE) {
- return;
- }
-
- if (zend_hash_quick_find(Z_OBJPROP_P(object), ref->prop->name, ref->prop->name_length
+ 1, ref->prop->h, (void **) &variable_ptr) == SUCCESS) {
- if (*variable_ptr == value) {
- setter_done = 1;
- } else {
- if (PZVAL_IS_REF(*variable_ptr)) {
- zval_dtor(*variable_ptr);
- (*variable_ptr)->type = value->type;
- (*variable_ptr)->value = value->value;
- if (value->refcount > 0) {
- zval_copy_ctor(*variable_ptr);
- }
- setter_done = 1;
+ if ((ref->prop->flags & ZEND_ACC_STATIC)) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z",
&value) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &tmp, &value) ==
FAILURE) {
+ return;
}
}
+ prop_table = intern->ce->static_members;
} else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oz", &object, &value) ==
FAILURE) {
+ return;
+ }
+ prop_table = Z_OBJPROP_P(object);
+ }
+
+ if (zend_hash_quick_find(prop_table, ref->prop->name, ref->prop->name_length + 1,
ref->prop->h, (void **) &variable_ptr) == FAILURE) {
zend_error(E_ERROR, "Internal error: Could not find the property %s",
ref->prop->name);
/* Bails out */
}
-
+ if (*variable_ptr == value) {
+ setter_done = 1;
+ } else {
+ if (PZVAL_IS_REF(*variable_ptr)) {
+ zval_dtor(*variable_ptr);
+ (*variable_ptr)->type = value->type;
+ (*variable_ptr)->value = value->value;
+ if (value->refcount > 0) {
+ zval_copy_ctor(*variable_ptr);
+ }
+ setter_done = 1;
+ }
+ }
if (!setter_done) {
zval **foo;
@@ -3111,7 +3120,7 @@
if (PZVAL_IS_REF(value)) {
SEPARATE_ZVAL(&value);
}
- zend_hash_quick_update(Z_OBJPROP_P(object), ref->prop->name,
ref->prop->name_length+1, ref->prop->h, &value, sizeof(zval *), (void **) &foo);
+ zend_hash_quick_update(prop_table, ref->prop->name, ref->prop->name_length+1,
ref->prop->h, &value, sizeof(zval *), (void **) &foo);
}
}
/* }}} */