ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
/* If filename is NULL the default filename is used. */
ZEND_API ZEND_COLD void zend_error_at(int type, const char *filename, uint32_t lineno, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 4, 5);
+ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_at_noreturn(int type, const char *filename, uint32_t lineno, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 4, 5);
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_API ZEND_COLD void zend_type_error(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
}
/* }}} */
+static zend_always_inline uint32_t func_lineno(zend_function *fn) {
+ return fn->common.type == ZEND_USER_FUNCTION ? fn->op_array.line_start : 0;
+}
+
static void do_inheritance_check_on_method(zend_function *child, zend_function *parent, zend_class_entry *ce, zval *child_zv) /* {{{ */
{
uint32_t child_flags;
uint32_t parent_flags = parent->common.fn_flags;
if (UNEXPECTED(parent_flags & ZEND_ACC_FINAL)) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot override final method %s::%s()", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name));
+ zend_error_at_noreturn(E_COMPILE_ERROR, NULL, func_lineno(child),
+ "Cannot override final method %s::%s()",
+ ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name));
}
child_flags = child->common.fn_flags;
*/
if (UNEXPECTED((child_flags & ZEND_ACC_STATIC) != (parent_flags & ZEND_ACC_STATIC))) {
if (child_flags & ZEND_ACC_STATIC) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot make non static method %s::%s() static in class %s", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child));
+ zend_error_at_noreturn(E_COMPILE_ERROR, NULL, func_lineno(child),
+ "Cannot make non static method %s::%s() static in class %s",
+ ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child));
} else {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot make static method %s::%s() non static in class %s", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child));
+ zend_error_at_noreturn(E_COMPILE_ERROR, NULL, func_lineno(child),
+ "Cannot make static method %s::%s() non static in class %s",
+ ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child));
}
}
/* Disallow making an inherited method abstract. */
if (UNEXPECTED((child_flags & ZEND_ACC_ABSTRACT) > (parent_flags & ZEND_ACC_ABSTRACT))) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot make non abstract method %s::%s() abstract in class %s", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child));
+ zend_error_at_noreturn(E_COMPILE_ERROR, NULL, func_lineno(child),
+ "Cannot make non abstract method %s::%s() abstract in class %s",
+ ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child));
}
if (parent_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_CHANGED)) {
}
/* Prevent derived classes from restricting access that was available in parent classes (except deriving from non-abstract ctors) */
if ((child_flags & ZEND_ACC_PPP_MASK) > (parent_flags & ZEND_ACC_PPP_MASK)) {
- zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::%s() must be %s (as in class %s)%s", ZEND_FN_SCOPE_NAME(child), ZSTR_VAL(child->common.function_name), zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
+ zend_error_at_noreturn(E_COMPILE_ERROR, NULL, func_lineno(child),
+ "Access level to %s::%s() must be %s (as in class %s)%s",
+ ZEND_FN_SCOPE_NAME(child), ZSTR_VAL(child->common.function_name), zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
}
if (UNEXPECTED(!zend_do_perform_implementation_check(child, parent))) {
error_level = E_WARNING;
error_verb = "should";
}
- zend_error_at(error_level, NULL,
- child->common.type == ZEND_USER_FUNCTION ? child->op_array.line_start : 0,
+ zend_error_at(error_level, NULL, func_lineno(child),
"Declaration of %s %s be compatible with %s",
ZSTR_VAL(child_prototype), error_verb, ZSTR_VAL(method_prototype));
zend_string_efree(child_prototype);