]> granicus.if.org Git - php/commitdiff
Remove bogus ctor checks in get_class_methods() + reflection
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 14 Feb 2019 10:28:13 +0000 (11:28 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 14 Feb 2019 10:47:31 +0000 (11:47 +0100)
Contrary to the comments, these only hide constructors (old or new
style) if they a) are inherited b) come from a trait and c) are
aliased -- which doesn't make any sense at all.

Zend/zend_builtin_functions.c
ext/reflection/php_reflection.c

index 93bbd3bc87a0d98a5ce99a4e09b5c3a3e79d8d1d..2b16991d1cb2067272721e2edc1351c81e455d3c 100644 (file)
@@ -1284,26 +1284,16 @@ ZEND_FUNCTION(get_class_methods)
                     (((mptr->common.fn_flags & ZEND_ACC_PROTECTED) &&
                       zend_check_protected(mptr->common.scope, scope))
                   || ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) &&
-                      scope == mptr->common.scope)))) {
-                       size_t len = ZSTR_LEN(mptr->common.function_name);
-
-                       /* Do not display old-style inherited constructors */
-                       if (!key) {
+                      scope == mptr->common.scope)))
+               ) {
+                       if (mptr->type == ZEND_USER_FUNCTION &&
+                               (!mptr->op_array.refcount || *mptr->op_array.refcount > 1) &&
+                                key && !same_name(key, mptr->common.function_name)) {
+                               ZVAL_STR_COPY(&method_name, zend_find_alias_name(mptr->common.scope, key));
+                               zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
+                       } else {
                                ZVAL_STR_COPY(&method_name, mptr->common.function_name);
                                zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
-                       } else if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
-                           mptr->common.scope == ce ||
-                           zend_binary_strcasecmp(ZSTR_VAL(key), ZSTR_LEN(key), ZSTR_VAL(mptr->common.function_name), len) == 0) {
-
-                               if (mptr->type == ZEND_USER_FUNCTION &&
-                                   (!mptr->op_array.refcount || *mptr->op_array.refcount > 1) &&
-                                !same_name(key, mptr->common.function_name)) {
-                                       ZVAL_STR_COPY(&method_name, zend_find_alias_name(mptr->common.scope, key));
-                                       zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
-                               } else {
-                                       ZVAL_STR_COPY(&method_name, mptr->common.function_name);
-                                       zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
-                               }
                        }
                }
        } ZEND_HASH_FOREACH_END();
index 8bfafe7c5a2c638627b65666c1784b7967f0937a..17737454be01bd6c5763114c7c777f77a1a49bba 100644 (file)
@@ -474,36 +474,26 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
        count = zend_hash_num_elements(&ce->function_table) - count_static_funcs;
        if (count > 0) {
                zend_function *mptr;
-               zend_string *key;
                smart_str method_str = {0};
 
                count = 0;
-               ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->function_table, key, mptr) {
+               ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) {
                        if ((mptr->common.fn_flags & ZEND_ACC_STATIC) == 0
                                && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
                        {
-                               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
-                                       || mptr->common.scope == ce
-                                       || !key
-                                       || zend_binary_strcasecmp(ZSTR_VAL(key), ZSTR_LEN(key), ZSTR_VAL(mptr->common.function_name), len) == 0)
+                               zend_function *closure;
+                               /* see if this is a closure */
+                               if (obj && is_closure_invoke(ce, mptr->common.function_name)
+                                       && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj))) != NULL)
                                {
-                                       zend_function *closure;
-                                       /* see if this is a closure */
-                                       if (obj && is_closure_invoke(ce, mptr->common.function_name)
-                                               && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj))) != NULL)
-                                       {
-                                               mptr = closure;
-                                       } else {
-                                               closure = NULL;
-                                       }
-                                       smart_str_appendc(&method_str, '\n');
-                                       _function_string(&method_str, mptr, ce, ZSTR_VAL(sub_indent));
-                                       count++;
-                                       _free_function(closure);
+                                       mptr = closure;
+                               } else {
+                                       closure = NULL;
                                }
+                               smart_str_appendc(&method_str, '\n');
+                               _function_string(&method_str, mptr, ce, ZSTR_VAL(sub_indent));
+                               count++;
+                               _free_function(closure);
                        }
                } ZEND_HASH_FOREACH_END();
                smart_str_append_printf(str, "\n%s  - Methods [%d] {", indent, count);