}
/* }}} */
-ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type) /* {{{ */
+ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, zend_string *lcname, int error_type) /* {{{ */
{
- zend_string *lcname;
-
if (ZSTR_VAL(fptr->common.function_name)[0] != '_'
|| ZSTR_VAL(fptr->common.function_name)[1] != '_') {
return;
}
- lcname = zend_string_tolower(fptr->common.function_name);
-
if (zend_string_equals_literal(lcname, ZEND_DESTRUCTOR_FUNC_NAME) && fptr->common.num_args != 0) {
zend_error(error_type, "Destructor %s::%s() cannot take arguments", ZSTR_VAL(ce->name), ZEND_DESTRUCTOR_FUNC_NAME);
} else if (zend_string_equals_literal(lcname, ZEND_CLONE_FUNC_NAME) && fptr->common.num_args != 0) {
} else if (zend_string_equals_literal(lcname, "__unserialize") && fptr->common.num_args != 1) {
zend_error(error_type, "Method %s::__unserialize() must take exactly 1 argument", ZSTR_VAL(ce->name));
}
-
- zend_string_release_ex(lcname, 0);
}
/* }}} */
reg_function = NULL;
}
if (reg_function) {
- zend_check_magic_method_implementation(scope, reg_function, error_type);
+ zend_check_magic_method_implementation(
+ scope, reg_function, lowercase_name, error_type);
}
}
ptr++;
ZEND_API int zend_startup_modules(void);
ZEND_API void zend_collect_module_handlers(void);
ZEND_API void zend_destroy_modules(void);
-ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type);
+ZEND_API void zend_check_magic_method_implementation(
+ const zend_class_entry *ce, const zend_function *fptr, zend_string *lcname, int error_type);
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry);
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce);
zend_string_init("stringable", sizeof("stringable") - 1, 0);
}
-void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_bool has_body) /* {{{ */
+zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_bool has_body) /* {{{ */
{
zend_class_entry *ce = CG(active_class_entry);
zend_bool in_interface = (ce->ce_flags & ZEND_ACC_INTERFACE) != 0;
zend_check_magic_method_attr(fn_flags, ce, "__unserialize", 0);
}
- zend_string_release_ex(lcname, 0);
+ return lcname;
}
/* }}} */
zend_ast *stmt_ast = decl->child[2];
zend_ast *return_type_ast = decl->child[3];
zend_bool is_method = decl->kind == ZEND_AST_METHOD;
+ zend_string *method_lcname;
zend_class_entry *orig_class_entry = CG(active_class_entry);
zend_op_array *orig_op_array = CG(active_op_array);
if (is_method) {
zend_bool has_body = stmt_ast != NULL;
- zend_begin_method_decl(op_array, decl->name, has_body);
+ method_lcname = zend_begin_method_decl(op_array, decl->name, has_body);
} else {
zend_begin_func_decl(result, op_array, decl, toplevel);
if (decl->kind == ZEND_AST_ARROW_FUNC) {
if (is_method) {
zend_check_magic_method_implementation(
- CG(active_class_entry), (zend_function *) op_array, E_COMPILE_ERROR);
+ CG(active_class_entry), (zend_function *) op_array, method_lcname, E_COMPILE_ERROR);
+ zend_string_release_ex(method_lcname, 0);
}
/* put the implicit return on the really last line */