]> granicus.if.org Git - php/commitdiff
Get rid of ZEND_ACC_IMPLICIT_PUBLIC
authorDmitry Stogov <dmitry@zend.com>
Tue, 11 Sep 2018 09:26:26 +0000 (12:26 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 11 Sep 2018 09:26:26 +0000 (12:26 +0300)
UPGRADING.INTERNALS
Zend/zend_compile.h
ext/reflection/php_reflection.c

index b9126ed3879c522f2eaa8c80784d96fe94d09727..c619a4b220f793f82a88ce92ec4240a95d27120a 100644 (file)
@@ -29,6 +29,7 @@ PHP 7.4 INTERNALS UPGRADE NOTES
       (func->commpon.scope->constructor == func).
     - ZEND_ACC_IMPLEMENTED_ABSTRACT is removed (it was used only internally
       during inheritance).
+    - ZEND_ACC_IMPLICIT_PUBLIC is removed (it was used only for reflection)
     - ZEND_ACC_SHADOW property flag is removed. Instead of creating shadow
       clone, now we use the same private property_info, and should also
       check property_info->ce (in the same way as with methods).
index ba4550579ea32db420f67438e7a157c4ce0b67f8..bcc482382a0bec0e1b2bd9858a6be943cf8653b5 100644 (file)
@@ -215,9 +215,6 @@ typedef struct _zend_oparray_context {
 /* Property or method overrides private one               |     |     |     */
 #define ZEND_ACC_CHANGED                 (1 << 11) /*     |  X  |  X  |     */
 /*                                                        |     |     |     */
-/* TODO: used only by ext/reflection ???                  |     |     |     */
-#define ZEND_ACC_IMPLICIT_PUBLIC         (1 << 12) /*     |  ?  |  ?  |  ?  */
-/*                                                        |     |     |     */
 /* Class Flags (unused: 0, 1, 3, 11-18, 21, 25...)        |     |     |     */
 /* ===========                                            |     |     |     */
 /*                                                        |     |     |     */
index fbacb9e92ef8fd91a3c654e6d34eb2d312d22a85..559612b0d7d70276e769b978f928236e9ca36dd3 100644 (file)
@@ -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));