From 9a1797d48e35bf876b4621f3af9e59f3f21ef53c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sun, 26 Apr 2015 15:12:10 +0200 Subject: [PATCH] Revert unrelated changes / rebase fixup --- Zend/zend_builtin_functions.c | 23 ++++++------------ Zend/zend_compile.c | 46 ++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index e36dbfd6e7..7313b32065 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -217,10 +217,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_create_function, 0, 0, 2) ZEND_ARG_INFO(0, code) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_get_defined_functions, 0, 0, 0) - ZEND_ARG_INFO(0, disabled) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_get_resource_type, 0, 0, 1) ZEND_ARG_INFO(0, res) ZEND_END_ARG_INFO() @@ -306,7 +302,7 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */ ZEND_FE(get_declared_classes, arginfo_zend__void) ZEND_FE(get_declared_traits, arginfo_zend__void) ZEND_FE(get_declared_interfaces, arginfo_zend__void) - ZEND_FE(get_defined_functions, arginfo_get_defined_functions) + ZEND_FE(get_defined_functions, arginfo_zend__void) ZEND_FE(get_defined_vars, arginfo_zend__void) ZEND_FE(create_function, arginfo_create_function) ZEND_FE(get_resource_type, arginfo_get_resource_type) @@ -1864,19 +1860,15 @@ ZEND_FUNCTION(get_declared_interfaces) static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { zend_function *func = Z_PTR_P(zv); - zval *internal_ar = va_arg(args, zval *), - *user_ar = va_arg(args, zval *); - zend_bool *disabled = va_arg(args, zend_bool*); + zval *internal_ar = va_arg(args, zval *), + *user_ar = va_arg(args, zval *); if (hash_key->key == NULL || hash_key->key->val[0] == 0) { return 0; } if (func->type == ZEND_INTERNAL_FUNCTION) { - zend_internal_function *intern = (zend_internal_function*) func; - if ((*disabled) || intern->handler != ZEND_FN(display_disabled_function)) { - add_next_index_str(internal_ar, zend_string_copy(hash_key->key)); - } + add_next_index_str(internal_ar, zend_string_copy(hash_key->key)); } else if (func->type == ZEND_USER_FUNCTION) { add_next_index_str(user_ar, zend_string_copy(hash_key->key)); } @@ -1885,14 +1877,13 @@ static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_ke } /* }}} */ -/* {{{ proto array get_defined_functions(bool disabled = false) +/* {{{ proto array get_defined_functions(void) Returns an array of all defined functions */ ZEND_FUNCTION(get_defined_functions) { zval internal, user; - zend_bool disabled = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &disabled) == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) { return; } @@ -1900,7 +1891,7 @@ ZEND_FUNCTION(get_defined_functions) array_init(&user); array_init(return_value); - zend_hash_apply_with_arguments(EG(function_table), copy_function_name, 3, &internal, &user, &disabled); + zend_hash_apply_with_arguments(EG(function_table), copy_function_name, 2, &internal, &user); zend_hash_str_add_new(Z_ARRVAL_P(return_value), "internal", sizeof("internal")-1, &internal); zend_hash_str_add_new(Z_ARRVAL_P(return_value), "user", sizeof("user")-1, &user); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 93f99c8628..952ea1cab6 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4983,8 +4983,7 @@ zend_class_entry *zend_compile_class_decl(zend_ast *ast) /* {{{ */ name = zend_prefix_with_ns(name); zend_string_release(lcname); - lcname = zend_string_alloc(name->len, 0); - zend_str_tolower_copy(lcname->val, name->val, name->len); + lcname = zend_string_tolower(name); } else { zend_string_addref(name); } @@ -4994,15 +4993,15 @@ zend_class_entry *zend_compile_class_decl(zend_ast *ast) /* {{{ */ "because the name is already in use", name->val); } - name = zend_new_interned_string(name TSRMLS_CC); - lcname = zend_new_interned_string(lcname TSRMLS_CC); + name = zend_new_interned_string(name); + lcname = zend_new_interned_string(lcname); ce->type = ZEND_USER_CLASS; ce->name = name; - zend_initialize_class_data(ce, 1 TSRMLS_CC); + zend_initialize_class_data(ce, 1); ce->ce_flags |= decl->flags; - ce->info.user.filename = zend_get_compiled_filename(TSRMLS_C); + ce->info.user.filename = zend_get_compiled_filename(); ce->info.user.line_start = decl->start_lineno; ce->info.user.line_end = decl->end_lineno; if (decl->doc_comment) { @@ -5010,12 +5009,6 @@ zend_class_entry *zend_compile_class_decl(zend_ast *ast) /* {{{ */ } if (extends_ast) { - if (ce->ce_flags & ZEND_ACC_TRAIT) { - zend_error_noreturn(E_COMPILE_ERROR, "A trait (%s) cannot extend a class. " - "Traits can only be composed from other traits with the 'use' keyword. Error", - name->val); - } - if (!zend_is_const_default_class_ref(extends_ast)) { zend_string *extends_name = zend_ast_get_str(extends_ast); zend_error_noreturn(E_COMPILE_ERROR, @@ -5025,8 +5018,8 @@ zend_class_entry *zend_compile_class_decl(zend_ast *ast) /* {{{ */ zend_compile_class_ref(&extends_node, extends_ast, 0); } - opline = get_next_op(CG(active_op_array) TSRMLS_CC); - zend_make_var_result(&declare_node, opline TSRMLS_CC); + opline = get_next_op(CG(active_op_array)); + zend_make_var_result(&declare_node, opline); // TODO.AST drop this GET_NODE(&FC(implementing_class), opline->result); @@ -5042,7 +5035,7 @@ zend_class_entry *zend_compile_class_decl(zend_ast *ast) /* {{{ */ } { - zend_string *key = zend_build_runtime_definition_key(lcname, decl->lex_pos TSRMLS_CC); + zend_string *key = zend_build_runtime_definition_key(lcname, decl->lex_pos); opline->op1_type = IS_CONST; LITERAL_STR(opline->op1, key); @@ -5053,10 +5046,10 @@ zend_class_entry *zend_compile_class_decl(zend_ast *ast) /* {{{ */ CG(active_class_entry) = ce; if (implements_ast) { - zend_compile_implements(&declare_node, implements_ast TSRMLS_CC); + zend_compile_implements(&declare_node, implements_ast); } - zend_compile_stmt(stmt_ast TSRMLS_CC); + zend_compile_stmt(stmt_ast); if (ce->num_traits == 0) { /* For traits this check is delayed until after trait binding */ @@ -5069,12 +5062,21 @@ zend_class_entry *zend_compile_class_decl(zend_ast *ast) /* {{{ */ zend_error_noreturn(E_COMPILE_ERROR, "Constructor %s::%s() cannot be static", ce->name->val, ce->constructor->common.function_name->val); } + if (ce->constructor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { + zend_error_noreturn(E_COMPILE_ERROR, + "Constructor %s::%s() cannot declare a return type", + ce->name->val, ce->constructor->common.function_name->val); + } } if (ce->destructor) { ce->destructor->common.fn_flags |= ZEND_ACC_DTOR; if (ce->destructor->common.fn_flags & ZEND_ACC_STATIC) { zend_error_noreturn(E_COMPILE_ERROR, "Destructor %s::%s() cannot be static", ce->name->val, ce->destructor->common.function_name->val); + } else if (ce->destructor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { + zend_error_noreturn(E_COMPILE_ERROR, + "Destructor %s::%s() cannot declare a return type", + ce->name->val, ce->destructor->common.function_name->val); } } if (ce->clone) { @@ -5082,6 +5084,10 @@ zend_class_entry *zend_compile_class_decl(zend_ast *ast) /* {{{ */ if (ce->clone->common.fn_flags & ZEND_ACC_STATIC) { zend_error_noreturn(E_COMPILE_ERROR, "Clone method %s::%s() cannot be static", ce->name->val, ce->clone->common.function_name->val); + } else if (ce->clone->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { + zend_error_noreturn(E_COMPILE_ERROR, + "%s::%s() cannot declare a return type", + ce->name->val, ce->clone->common.function_name->val); } } @@ -5093,15 +5099,15 @@ zend_class_entry *zend_compile_class_decl(zend_ast *ast) /* {{{ */ ce->num_traits = 0; ce->ce_flags |= ZEND_ACC_IMPLEMENT_TRAITS; - zend_emit_op(NULL, ZEND_BIND_TRAITS, &declare_node, NULL TSRMLS_CC); + zend_emit_op(NULL, ZEND_BIND_TRAITS, &declare_node, NULL); } if (!(ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) && (extends_ast || ce->num_interfaces > 0) ) { - zend_verify_abstract_class(ce TSRMLS_CC); + zend_verify_abstract_class(ce); if (ce->num_interfaces && !(ce->ce_flags & ZEND_ACC_IMPLEMENT_TRAITS)) { - zend_emit_op(NULL, ZEND_VERIFY_ABSTRACT_CLASS, &declare_node, NULL TSRMLS_CC); + zend_emit_op(NULL, ZEND_VERIFY_ABSTRACT_CLASS, &declare_node, NULL); } } -- 2.50.1