summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-09-11 12:26:26 +0300
committerDmitry Stogov <dmitry@zend.com>2018-09-11 12:26:26 +0300
commit034b7ff09143e3d86d6e4f8c15728b52b0c413d7 (patch)
tree64af57ffc4c0efcdca612b10bca8b9395e1e8843 /ext/reflection/php_reflection.c
parent5c39b2c328d002e81dd4889ca67a70e55b485861 (diff)
downloadphp-git-034b7ff09143e3d86d6e4f8c15728b52b0c413d7.tar.gz
Get rid of ZEND_ACC_IMPLICIT_PUBLIC
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index fbacb9e92e..559612b0d7 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -107,6 +107,7 @@ typedef struct _property_reference {
zend_class_entry *ce;
zend_property_info prop;
zend_string *unmangled_name;
+ zend_bool dynamic;
} property_reference;
/* Struct for parameters */
@@ -266,7 +267,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);
@@ -381,7 +382,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
if ((prop->flags & ZEND_ACC_STATIC) && (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) {
- _property_string(str, prop, NULL, ZSTR_VAL(sub_indent));
+ _property_string(str, prop, NULL, ZSTR_VAL(sub_indent), 0);
}
} ZEND_HASH_FOREACH_END();
}
@@ -429,7 +430,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
if (!(prop->flags & ZEND_ACC_STATIC)
&& (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) {
- _property_string(str, prop, NULL, ZSTR_VAL(sub_indent));
+ _property_string(str, prop, NULL, ZSTR_VAL(sub_indent), 0);
}
} ZEND_HASH_FOREACH_END();
}
@@ -446,7 +447,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();
@@ -823,14 +824,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> ");
@@ -1226,7 +1227,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;
@@ -1259,6 +1260,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_string *name,
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;
@@ -1271,7 +1273,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);
}
@@ -1495,9 +1497,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) {
@@ -3435,7 +3434,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) {
@@ -3605,7 +3604,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);
}
/* }}} */
@@ -4255,19 +4254,19 @@ 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_PRIVATE) || property_info->ce == ce) {
- reflection_property_factory(ce, name, property_info, return_value);
+ 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;
}
}
@@ -4355,11 +4354,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;
@@ -5320,12 +5319,14 @@ 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);
@@ -5348,7 +5349,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));
}
/* }}} */
@@ -5381,7 +5382,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);
}
/* }}} */
@@ -5413,7 +5414,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);
}
/* }}} */
@@ -5423,7 +5431,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;
@@ -5445,7 +5453,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));