summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c196
1 files changed, 101 insertions, 95 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index c2f6e198ad..af15675a65 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -75,38 +75,37 @@ PHPAPI zend_class_entry *reflection_extension_ptr;
PHPAPI zend_class_entry *reflection_zend_extension_ptr;
/* Exception throwing macro */
-#define _DO_THROW(msg) \
- zend_throw_exception(reflection_exception_ptr, msg, 0); \
- return; \
-
-#define RETURN_ON_EXCEPTION \
- if (EG(exception) && EG(exception)->ce == reflection_exception_ptr) { \
- return; \
- }
-
-#define GET_REFLECTION_OBJECT() \
- intern = Z_REFLECTION_P(getThis()); \
- if (intern->ptr == NULL) { \
- RETURN_ON_EXCEPTION \
- zend_throw_error(NULL, "Internal error: Failed to retrieve the reflection object"); \
- return; \
- } \
+#define _DO_THROW(msg) \
+ zend_throw_exception(reflection_exception_ptr, msg, 0); \
+ return;
+
+#define GET_REFLECTION_OBJECT() do { \
+ intern = Z_REFLECTION_P(getThis()); \
+ if (intern->ptr == NULL) { \
+ if (EG(exception) && EG(exception)->ce == reflection_exception_ptr) { \
+ return; \
+ } \
+ zend_throw_error(NULL, "Internal error: Failed to retrieve the reflection object"); \
+ return; \
+ } \
+} while (0)
-#define GET_REFLECTION_OBJECT_PTR(target) \
- GET_REFLECTION_OBJECT() \
- target = intern->ptr; \
+#define GET_REFLECTION_OBJECT_PTR(target) do { \
+ GET_REFLECTION_OBJECT(); \
+ target = intern->ptr; \
+} while (0)
/* Class constants */
-#define REGISTER_REFLECTION_CLASS_CONST_LONG(class_name, const_name, value) \
+#define REGISTER_REFLECTION_CLASS_CONST_LONG(class_name, const_name, value) \
zend_declare_class_constant_long(reflection_ ## class_name ## _ptr, const_name, sizeof(const_name)-1, (zend_long)value);
/* {{{ Object structure */
/* Struct for properties */
typedef struct _property_reference {
- zend_class_entry *ce;
zend_property_info prop;
zend_string *unmangled_name;
+ zend_bool dynamic;
} property_reference;
/* Struct for parameters */
@@ -119,8 +118,7 @@ typedef struct _parameter_reference {
/* Struct for type hints */
typedef struct _type_reference {
- struct _zend_arg_info *arg_info;
- zend_function *fptr;
+ zend_type type;
} type_reference;
typedef enum {
@@ -135,7 +133,6 @@ typedef enum {
/* Struct for reflection objects */
typedef struct {
- zval dummy; /* holder for the second property */
zval obj;
void *ptr;
zend_class_entry *ce;
@@ -203,7 +200,6 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */
reflection_object *intern = reflection_object_from_obj(object);
parameter_reference *reference;
property_reference *prop_reference;
- type_reference *typ_reference;
if (intern->ptr) {
switch (intern->ref_type) {
@@ -213,8 +209,6 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */
efree(intern->ptr);
break;
case REF_TYPE_TYPE:
- typ_reference = (type_reference*)intern->ptr;
- _free_function(typ_reference->fptr);
efree(intern->ptr);
break;
case REF_TYPE_FUNCTION:
@@ -266,7 +260,7 @@ static zval *reflection_instantiate(zend_class_entry *pce, zval *object) /* {{{
static void _const_string(smart_str *str, char *name, zval *value, char *indent);
static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, char* indent);
-static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent);
+static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent, zend_bool dynamic);
static void _class_const_string(smart_str *str, char *name, zend_class_constant *c, char* indent);
static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char *indent);
static void _extension_string(smart_str *str, zend_module_entry *module, char *indent);
@@ -324,6 +318,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
if (ce->num_interfaces) {
uint32_t i;
+ ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED);
if (ce->ce_flags & ZEND_ACC_INTERFACE) {
smart_str_append_printf(str, " extends %s", ZSTR_VAL(ce->interfaces[0]->name));
} else {
@@ -365,7 +360,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
zend_property_info *prop;
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
- if(prop->flags & ZEND_ACC_SHADOW) {
+ if ((prop->flags & ZEND_ACC_PRIVATE) && prop->ce != ce) {
count_shadow_props++;
} else if (prop->flags & ZEND_ACC_STATIC) {
count_static_props++;
@@ -379,8 +374,8 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
zend_property_info *prop;
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
- if ((prop->flags & ZEND_ACC_STATIC) && !(prop->flags & ZEND_ACC_SHADOW)) {
- _property_string(str, prop, NULL, ZSTR_VAL(sub_indent));
+ if ((prop->flags & ZEND_ACC_STATIC) && (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) {
+ _property_string(str, prop, NULL, ZSTR_VAL(sub_indent), 0);
}
} ZEND_HASH_FOREACH_END();
}
@@ -426,8 +421,9 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
zend_property_info *prop;
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
- if (!(prop->flags & (ZEND_ACC_STATIC|ZEND_ACC_SHADOW))) {
- _property_string(str, prop, NULL, ZSTR_VAL(sub_indent));
+ if (!(prop->flags & ZEND_ACC_STATIC)
+ && (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) {
+ _property_string(str, prop, NULL, ZSTR_VAL(sub_indent), 0);
}
} ZEND_HASH_FOREACH_END();
}
@@ -444,7 +440,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
if (prop_name && ZSTR_LEN(prop_name) && ZSTR_VAL(prop_name)[0]) { /* skip all private and protected properties */
if (!zend_hash_exists(&ce->properties_info, prop_name)) {
count++;
- _property_string(&prop_str, NULL, ZSTR_VAL(prop_name), ZSTR_VAL(sub_indent));
+ _property_string(&prop_str, NULL, ZSTR_VAL(prop_name), ZSTR_VAL(sub_indent), 0);
}
}
} ZEND_HASH_FOREACH_END();
@@ -471,7 +467,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
size_t len = ZSTR_LEN(mptr->common.function_name);
/* Do not display old-style inherited constructors */
- if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0
+ if (mptr->common.scope->constructor != mptr
|| mptr->common.scope == ce
|| !key
|| zend_binary_strcasecmp(ZSTR_VAL(key), ZSTR_LEN(key), ZSTR_VAL(mptr->common.function_name), len) == 0)
@@ -743,10 +739,10 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent
if (fptr->common.prototype && fptr->common.prototype->common.scope) {
smart_str_append_printf(str, ", prototype %s", ZSTR_VAL(fptr->common.prototype->common.scope->name));
}
- if (fptr->common.fn_flags & ZEND_ACC_CTOR) {
+ if (fptr->common.scope && fptr->common.scope->constructor == fptr) {
smart_str_appends(str, ", ctor");
}
- if (fptr->common.fn_flags & ZEND_ACC_DTOR) {
+ if (fptr->common.scope && fptr->common.scope->destructor == fptr) {
smart_str_appends(str, ", dtor");
}
smart_str_appends(str, "> ");
@@ -821,14 +817,14 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent
/* }}} */
/* {{{ _property_string */
-static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent)
+static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent, zend_bool dynamic)
{
smart_str_append_printf(str, "%sProperty [ ", indent);
if (!prop) {
smart_str_append_printf(str, "<dynamic> public $%s", prop_name);
} else {
if (!(prop->flags & ZEND_ACC_STATIC)) {
- if (prop->flags & ZEND_ACC_IMPLICIT_PUBLIC) {
+ if (dynamic) {
smart_str_appends(str, "<implicit> ");
} else {
smart_str_appends(str, "<default> ");
@@ -1158,7 +1154,7 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
/* }}} */
/* {{{ reflection_type_factory */
-static void reflection_type_factory(zend_function *fptr, zval *closure_object, struct _zend_arg_info *arg_info, zval *object)
+static void reflection_type_factory(zend_type type, zval *object)
{
reflection_object *intern;
type_reference *reference;
@@ -1166,15 +1162,9 @@ static void reflection_type_factory(zend_function *fptr, zval *closure_object, s
reflection_instantiate(reflection_named_type_ptr, object);
intern = Z_REFLECTION_P(object);
reference = (type_reference*) emalloc(sizeof(type_reference));
- reference->arg_info = arg_info;
- reference->fptr = fptr;
+ reference->type = type;
intern->ptr = reference;
intern->ref_type = REF_TYPE_TYPE;
- intern->ce = fptr->common.scope;
- if (closure_object) {
- Z_ADDREF_P(closure_object);
- ZVAL_COPY_VALUE(&intern->obj, closure_object);
- }
}
/* }}} */
@@ -1224,7 +1214,7 @@ static void reflection_method_factory(zend_class_entry *ce, zend_function *metho
/* }}} */
/* {{{ reflection_property_factory */
-static void reflection_property_factory(zend_class_entry *ce, zend_string *name, zend_property_info *prop, zval *object)
+static void reflection_property_factory(zend_class_entry *ce, zend_string *name, zend_property_info *prop, zval *object, zend_bool dynamic)
{
reflection_object *intern;
zval propname;
@@ -1241,7 +1231,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_string *name,
tmp_ce = tmp_ce->parent;
}
- if (tmp_info && !(tmp_info->flags & ZEND_ACC_SHADOW)) { /* found something and it's not a parent's private */
+ if (tmp_info && (!(tmp_info->flags & ZEND_ACC_PRIVATE) || tmp_info->ce == tmp_ce)) { /* found something and it's not a parent's private */
prop = tmp_info;
} else { /* not found, use initial value */
ce = store_ce;
@@ -1254,9 +1244,9 @@ static void reflection_property_factory(zend_class_entry *ce, zend_string *name,
reflection_instantiate(reflection_property_ptr, object);
intern = Z_REFLECTION_P(object);
reference = (property_reference*) emalloc(sizeof(property_reference));
- reference->ce = ce;
reference->prop = *prop;
reference->unmangled_name = zend_string_copy(name);
+ reference->dynamic = dynamic;
intern->ptr = reference;
intern->ref_type = REF_TYPE_PROPERTY;
intern->ce = ce;
@@ -1269,7 +1259,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_string *name,
static void reflection_property_factory_str(zend_class_entry *ce, const char *name_str, size_t name_len, zend_property_info *prop, zval *object)
{
zend_string *name = zend_string_init(name_str, name_len, 0);
- reflection_property_factory(ce, name, prop, object);
+ reflection_property_factory(ce, name, prop, object, 0);
zend_string_release(name);
}
@@ -1493,9 +1483,6 @@ ZEND_METHOD(reflection, getModifierNames)
if (modifiers & ZEND_ACC_FINAL) {
add_next_index_stringl(return_value, "final", sizeof("final")-1);
}
- if (modifiers & ZEND_ACC_IMPLICIT_PUBLIC) {
- add_next_index_stringl(return_value, "public", sizeof("public")-1);
- }
/* These are mutually exclusive */
switch (modifiers & ZEND_ACC_PPP_MASK) {
@@ -2601,7 +2588,7 @@ ZEND_METHOD(reflection_parameter, getType)
if (!ZEND_TYPE_IS_SET(param->arg_info->type)) {
RETURN_NULL();
}
- reflection_type_factory(_copy_function(param->fptr), Z_ISUNDEF(intern->obj)? NULL : &intern->obj, param->arg_info, return_value);
+ reflection_type_factory(param->arg_info->type, return_value);
}
/* }}} */
@@ -2859,7 +2846,7 @@ ZEND_METHOD(reflection_type, allowsNull)
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->arg_info->type));
+ RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->type));
}
/* }}} */
@@ -2875,16 +2862,16 @@ ZEND_METHOD(reflection_type, isBuiltin)
}
GET_REFLECTION_OBJECT_PTR(param);
- RETVAL_BOOL(ZEND_TYPE_IS_CODE(param->arg_info->type));
+ RETVAL_BOOL(ZEND_TYPE_IS_CODE(param->type));
}
/* }}} */
/* {{{ reflection_type_name */
static zend_string *reflection_type_name(type_reference *param) {
- if (ZEND_TYPE_IS_CLASS(param->arg_info->type)) {
- return zend_string_copy(ZEND_TYPE_NAME(param->arg_info->type));
+ if (ZEND_TYPE_IS_CLASS(param->type)) {
+ return zend_string_copy(ZEND_TYPE_NAME(param->type));
} else {
- char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->arg_info->type));
+ char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->type));
return zend_string_init(name, strlen(name), 0);
}
}
@@ -3390,7 +3377,7 @@ ZEND_METHOD(reflection_function, getReturnType)
RETURN_NULL();
}
- reflection_type_factory(_copy_function(fptr), Z_ISUNDEF(intern->obj)? NULL : &intern->obj, &fptr->common.arg_info[-1], return_value);
+ reflection_type_factory(fptr->common.arg_info[-1].type, return_value);
}
/* }}} */
@@ -3408,7 +3395,7 @@ ZEND_METHOD(reflection_method, isConstructor)
/* we need to check if the ctor is the ctor of the class level we we
* looking at since we might be looking at an inherited old style ctor
* defined in base class. */
- RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_CTOR && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope);
+ RETURN_BOOL(intern->ce->constructor == mptr);
}
/* }}} */
@@ -3423,7 +3410,7 @@ ZEND_METHOD(reflection_method, isDestructor)
return;
}
GET_REFLECTION_OBJECT_PTR(mptr);
- RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_DTOR);
+ RETURN_BOOL(intern->ce->destructor == mptr);
}
/* }}} */
@@ -3433,7 +3420,7 @@ ZEND_METHOD(reflection_method, getModifiers)
{
reflection_object *intern;
zend_function *mptr;
- uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_IMPLICIT_PUBLIC
+ uint32_t keep_flags = ZEND_ACC_PPP_MASK
| ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL;
if (zend_parse_parameters_none() == FAILURE) {
@@ -3603,7 +3590,7 @@ static void _class_constant_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /
Returns whether this constant is public */
ZEND_METHOD(reflection_class_constant, isPublic)
{
- _class_constant_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC);
+ _class_constant_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC);
}
/* }}} */
@@ -3763,9 +3750,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
zend_string *key;
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->properties_info, key, prop_info) {
- if (((prop_info->flags & ZEND_ACC_SHADOW) &&
- prop_info->ce != ce) ||
- ((prop_info->flags & ZEND_ACC_PROTECTED) &&
+ if (((prop_info->flags & ZEND_ACC_PROTECTED) &&
!zend_check_protected(prop_info->ce, ce)) ||
((prop_info->flags & ZEND_ACC_PRIVATE) &&
prop_info->ce != ce)) {
@@ -4219,7 +4204,7 @@ ZEND_METHOD(reflection_class, hasProperty)
GET_REFLECTION_OBJECT_PTR(ce);
if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
- if (property_info->flags & ZEND_ACC_SHADOW) {
+ if ((property_info->flags & ZEND_ACC_PRIVATE) && property_info->ce != ce) {
RETURN_FALSE;
}
RETURN_TRUE;
@@ -4254,20 +4239,20 @@ ZEND_METHOD(reflection_class, getProperty)
GET_REFLECTION_OBJECT_PTR(ce);
if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
- if ((property_info->flags & ZEND_ACC_SHADOW) == 0) {
- reflection_property_factory(ce, name, property_info, return_value);
+ if (!(property_info->flags & ZEND_ACC_PRIVATE) || property_info->ce == ce) {
+ reflection_property_factory(ce, name, property_info, return_value, 0);
return;
}
} else if (Z_TYPE(intern->obj) != IS_UNDEF) {
/* Check for dynamic properties */
if (zend_hash_exists(Z_OBJ_HT(intern->obj)->get_properties(&intern->obj), name)) {
zend_property_info property_info_tmp;
- property_info_tmp.flags = ZEND_ACC_IMPLICIT_PUBLIC;
+ property_info_tmp.flags = ZEND_ACC_PUBLIC;
property_info_tmp.name = name;
property_info_tmp.doc_comment = NULL;
property_info_tmp.ce = ce;
- reflection_property_factory(ce, name, &property_info_tmp, return_value);
+ reflection_property_factory(ce, name, &property_info_tmp, return_value, 1);
return;
}
}
@@ -4296,7 +4281,10 @@ ZEND_METHOD(reflection_class, getProperty)
}
ce = ce2;
- if ((property_info = zend_hash_str_find_ptr(&ce->properties_info, str_name, str_name_len)) != NULL && (property_info->flags & ZEND_ACC_SHADOW) == 0) {
+ property_info = zend_hash_str_find_ptr(&ce->properties_info, str_name, str_name_len);
+ if (property_info != NULL
+ && (!(property_info->flags & ZEND_ACC_PRIVATE)
+ || property_info->ce == ce)) {
reflection_property_factory_str(ce, str_name, str_name_len, property_info, return_value);
return;
}
@@ -4315,7 +4303,7 @@ static int _addproperty(zval *el, int num_args, va_list args, zend_hash_key *has
zval *retval = va_arg(args, zval*);
long filter = va_arg(args, long);
- if (pptr->flags & ZEND_ACC_SHADOW) {
+ if ((pptr->flags & ZEND_ACC_PRIVATE) && pptr->ce != ce) {
return 0;
}
@@ -4338,7 +4326,7 @@ static int _adddynproperty(zval *ptr, int num_args, va_list args, zend_hash_key
zval *retval = va_arg(args, zval*);
/* under some circumstances, the properties hash table may contain numeric
- * properties (e.g. when casting from array). This is a WONT FIX bug, at
+ * properties (e.g. when casting from array). This is a WON'T FIX bug, at
* least for the moment. Ignore these */
if (hash_key->key == NULL) {
return 0;
@@ -4352,11 +4340,11 @@ static int _adddynproperty(zval *ptr, int num_args, va_list args, zend_hash_key
zend_property_info property_info;
property_info.doc_comment = NULL;
- property_info.flags = ZEND_ACC_IMPLICIT_PUBLIC;
+ property_info.flags = ZEND_ACC_PUBLIC;
property_info.name = hash_key->key;
property_info.ce = ce;
property_info.offset = -1;
- reflection_property_factory(ce, hash_key->key, &property_info, &property);
+ reflection_property_factory(ce, hash_key->key, &property_info, &property, 1);
add_next_index_zval(retval, &property);
}
return 0;
@@ -4829,6 +4817,7 @@ ZEND_METHOD(reflection_class, getInterfaces)
if (ce->num_interfaces) {
uint32_t i;
+ ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED);
array_init(return_value);
for (i=0; i < ce->num_interfaces; i++) {
zval interface;
@@ -4860,6 +4849,7 @@ ZEND_METHOD(reflection_class, getInterfaceNames)
return;
}
+ ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED);
array_init(return_value);
for (i=0; i < ce->num_interfaces; i++) {
@@ -4890,8 +4880,13 @@ ZEND_METHOD(reflection_class, getTraits)
for (i=0; i < ce->num_traits; i++) {
zval trait;
- zend_reflection_class_factory(ce->traits[i], &trait);
- zend_hash_update(Z_ARRVAL_P(return_value), ce->traits[i]->name, &trait);
+ zend_class_entry *trait_ce;
+
+ trait_ce = zend_fetch_class_by_name(ce->trait_names[i].name,
+ ce->trait_names[i].lc_name, ZEND_FETCH_CLASS_TRAIT);
+ ZEND_ASSERT(trait_ce);
+ zend_reflection_class_factory(trait_ce, &trait);
+ zend_hash_update(Z_ARRVAL_P(return_value), ce->trait_names[i].name, &trait);
}
}
/* }}} */
@@ -4917,7 +4912,7 @@ ZEND_METHOD(reflection_class, getTraitNames)
array_init(return_value);
for (i=0; i < ce->num_traits; i++) {
- add_next_index_str(return_value, zend_string_copy(ce->traits[i]->name));
+ add_next_index_str(return_value, zend_string_copy(ce->trait_names[i].name));
}
}
/* }}} */
@@ -5270,7 +5265,10 @@ ZEND_METHOD(reflection_property, __construct)
/* returns out of this function */
}
- if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) == NULL || (property_info->flags & ZEND_ACC_SHADOW)) {
+ property_info = zend_hash_find_ptr(&ce->properties_info, name);
+ if (property_info == NULL
+ || ((property_info->flags & ZEND_ACC_PRIVATE)
+ && property_info->ce != ce)) {
/* Check for dynamic properties */
if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT && Z_OBJ_HT_P(classname)->get_properties) {
if (zend_hash_exists(Z_OBJ_HT_P(classname)->get_properties(classname), name)) {
@@ -5307,14 +5305,15 @@ ZEND_METHOD(reflection_property, __construct)
reference = (property_reference*) emalloc(sizeof(property_reference));
if (dynam_prop) {
- reference->prop.flags = ZEND_ACC_IMPLICIT_PUBLIC;
+ reference->prop.flags = ZEND_ACC_PUBLIC;
reference->prop.name = name;
reference->prop.doc_comment = NULL;
reference->prop.ce = ce;
+ reference->dynamic = 1;
} else {
reference->prop = *property_info;
+ reference->dynamic = 0;
}
- reference->ce = ce;
reference->unmangled_name = zend_string_copy(name);
intern->ptr = reference;
intern->ref_type = REF_TYPE_PROPERTY;
@@ -5335,7 +5334,7 @@ ZEND_METHOD(reflection_property, __toString)
return;
}
GET_REFLECTION_OBJECT_PTR(ref);
- _property_string(&str, &ref->prop, ZSTR_VAL(ref->unmangled_name), "");
+ _property_string(&str, &ref->prop, ZSTR_VAL(ref->unmangled_name), "", ref->dynamic);
RETURN_STR(smart_str_extract(&str));
}
/* }}} */
@@ -5368,7 +5367,7 @@ static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /* {{{
Returns whether this property is public */
ZEND_METHOD(reflection_property, isPublic)
{
- _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC);
+ _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC);
}
/* }}} */
@@ -5400,7 +5399,14 @@ ZEND_METHOD(reflection_property, isStatic)
Returns whether this property is default (declared at compilation time). */
ZEND_METHOD(reflection_property, isDefault)
{
- _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ~ZEND_ACC_IMPLICIT_PUBLIC);
+ reflection_object *intern;
+ property_reference *ref;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+ GET_REFLECTION_OBJECT_PTR(ref);
+ RETURN_BOOL(!ref->dynamic);
}
/* }}} */
@@ -5410,7 +5416,7 @@ ZEND_METHOD(reflection_property, getModifiers)
{
reflection_object *intern;
property_reference *ref;
- uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_IMPLICIT_PUBLIC | ZEND_ACC_STATIC;
+ uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -5432,7 +5438,7 @@ ZEND_METHOD(reflection_property, getValue)
GET_REFLECTION_OBJECT_PTR(ref);
- if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) {
+ if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
name = _default_load_name(getThis());
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Cannot access non-public member %s::$%s", ZSTR_VAL(intern->ce->name), Z_STRVAL_P(name));
@@ -5440,7 +5446,7 @@ ZEND_METHOD(reflection_property, getValue)
}
if (ref->prop.flags & ZEND_ACC_STATIC) {
- member_p = zend_read_static_property_ex(ref->ce, ref->unmangled_name, 0);
+ member_p = zend_read_static_property_ex(intern->ce, ref->unmangled_name, 0);
if (member_p) {
ZVAL_COPY_DEREF(return_value, member_p);
}
@@ -5456,7 +5462,7 @@ ZEND_METHOD(reflection_property, getValue)
/* Returns from this function */
}
- member_p = zend_read_property_ex(ref->ce, object, ref->unmangled_name, 0, &rv);
+ member_p = zend_read_property_ex(intern->ce, object, ref->unmangled_name, 0, &rv);
if (member_p != &rv) {
ZVAL_COPY_DEREF(return_value, member_p);
} else {
@@ -5495,13 +5501,13 @@ ZEND_METHOD(reflection_property, setValue)
}
}
- zend_update_static_property_ex(ref->ce, ref->unmangled_name, value);
+ zend_update_static_property_ex(intern->ce, ref->unmangled_name, value);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "oz", &object, &value) == FAILURE) {
return;
}
- zend_update_property_ex(ref->ce, object, ref->unmangled_name, value);
+ zend_update_property_ex(intern->ce, object, ref->unmangled_name, value);
}
}
/* }}} */
@@ -5520,9 +5526,9 @@ ZEND_METHOD(reflection_property, getDeclaringClass)
}
GET_REFLECTION_OBJECT_PTR(ref);
- ce = tmp_ce = ref->ce;
+ ce = tmp_ce = intern->ce;
while (tmp_ce && (tmp_info = zend_hash_find_ptr(&tmp_ce->properties_info, ref->unmangled_name)) != NULL) {
- if (tmp_info->flags & ZEND_ACC_PRIVATE || tmp_info->flags & ZEND_ACC_SHADOW) {
+ if (tmp_info->flags & ZEND_ACC_PRIVATE) {
/* it's a private property, so it can't be inherited */
break;
}