Skip to content

Commit 3447c58

Browse files
authored
Zend: no need to fetch method name for constructor (php#22153)
1 parent 5a9f7c5 commit 3447c58

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

Zend/zend_inheritance.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
188188

189189
if (ce->constructor) {
190190
if (parent->constructor && UNEXPECTED(parent->constructor->common.fn_flags & ZEND_ACC_FINAL)) {
191-
zend_error_noreturn(E_ERROR, "Cannot override final %s::%s() with %s::%s()",
192-
ZSTR_VAL(parent->name), ZSTR_VAL(parent->constructor->common.function_name),
193-
ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name));
191+
zend_error_noreturn(E_ERROR, "Cannot override final %s::__construct() with %s::__construct()",
192+
ZSTR_VAL(parent->name),
193+
ZSTR_VAL(ce->name));
194194
}
195195
return;
196196
}

Zend/zend_object_handlers.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,12 +2176,16 @@ ZEND_API ZEND_COLD bool zend_std_unset_static_property(const zend_class_entry *c
21762176
static ZEND_COLD zend_never_inline void zend_bad_constructor_call(const zend_function *constructor, const zend_class_entry *scope) /* {{{ */
21772177
{
21782178
if (scope) {
2179-
zend_throw_error(NULL, "Call to %s %s::%s() from scope %s",
2180-
zend_visibility_string(constructor->common.fn_flags), ZSTR_VAL(constructor->common.scope->name),
2181-
ZSTR_VAL(constructor->common.function_name), ZSTR_VAL(scope->name)
2179+
zend_throw_error(NULL, "Call to %s %s::__construct() from scope %s",
2180+
zend_visibility_string(constructor->common.fn_flags),
2181+
ZSTR_VAL(constructor->common.scope->name),
2182+
ZSTR_VAL(scope->name)
21822183
);
21832184
} else {
2184-
zend_throw_error(NULL, "Call to %s %s::%s() from global scope", zend_visibility_string(constructor->common.fn_flags), ZSTR_VAL(constructor->common.scope->name), ZSTR_VAL(constructor->common.function_name));
2185+
zend_throw_error(NULL, "Call to %s %s::__construct() from global scope",
2186+
zend_visibility_string(constructor->common.fn_flags),
2187+
ZSTR_VAL(constructor->common.scope->name)
2188+
);
21852189
}
21862190
}
21872191
/* }}} */

0 commit comments

Comments
 (0)