summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-29 16:03:24 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-01-30 09:19:02 +0100
commit6c73b50cf6cf71be26700ce168d5e69350637d71 (patch)
tree63442d7344ac41468c4f22a193a2e1214993b1bd /Zend/zend_API.c
parent4eb5db2c68ecab4fd50a5e1950fdd6eb3703b899 (diff)
downloadphp-git-6c73b50cf6cf71be26700ce168d5e69350637d71.tar.gz
Remove static calls to non-static methods
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c65
1 files changed, 13 insertions, 52 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 2ec6d34145..12309afd9e 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -768,23 +768,17 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
}
if (zend_fcall_info_init(arg, 0, fci, fcc, NULL, &is_callable_error) == SUCCESS) {
- if (is_callable_error) {
- *severity = E_DEPRECATED;
- zend_spprintf(error, 0, "to be a valid callback, %s", is_callable_error);
- efree(is_callable_error);
- *spec = spec_walk;
- return "";
- }
+ ZEND_ASSERT(!is_callable_error);
break;
+ }
+
+ if (is_callable_error) {
+ *severity = E_ERROR;
+ zend_spprintf(error, 0, "to be a valid callback, %s", is_callable_error);
+ efree(is_callable_error);
+ return "";
} else {
- if (is_callable_error) {
- *severity = E_ERROR;
- zend_spprintf(error, 0, "to be a valid callback, %s", is_callable_error);
- efree(is_callable_error);
- return "";
- } else {
- return "valid callback";
- }
+ return "valid callback";
}
}
@@ -2338,25 +2332,21 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
if (ctor->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Constructor %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(ctor->common.function_name));
}
- ctor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (dtor) {
if (dtor->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Destructor %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(dtor->common.function_name));
}
- dtor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (clone) {
if (clone->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "%s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(clone->common.function_name));
}
- clone->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__call) {
if (__call->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(__call->common.function_name));
}
- __call->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__callstatic) {
if (!(__callstatic->common.fn_flags & ZEND_ACC_STATIC)) {
@@ -2368,31 +2358,26 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
if (__tostring->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(__tostring->common.function_name));
}
- __tostring->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__get) {
if (__get->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(__get->common.function_name));
}
- __get->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__set) {
if (__set->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(__set->common.function_name));
}
- __set->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__unset) {
if (__unset->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(__unset->common.function_name));
}
- __unset->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__isset) {
if (__isset->common.fn_flags & ZEND_ACC_STATIC) {
zend_error(error_type, "Method %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(__isset->common.function_name));
}
- __isset->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
}
if (__debugInfo) {
if (__debugInfo->common.fn_flags & ZEND_ACC_STATIC) {
@@ -3079,38 +3064,14 @@ get_function_via_handler:
if (retval) {
if (fcc->calling_scope && !call_via_handler) {
if (fcc->function_handler->common.fn_flags & ZEND_ACC_ABSTRACT) {
+ retval = 0;
if (error) {
zend_spprintf(error, 0, "cannot call abstract method %s::%s()", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name));
- retval = 0;
- } else {
- zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name));
- retval = 0;
}
} else if (!fcc->object && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) {
- int severity;
- char *verb;
- if (fcc->function_handler->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
- severity = E_DEPRECATED;
- verb = "should not";
- } else {
- /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
- severity = E_ERROR;
- verb = "cannot";
- }
- if ((check_flags & IS_CALLABLE_CHECK_IS_STATIC) != 0) {
- retval = 0;
- }
+ retval = 0;
if (error) {
- zend_spprintf(error, 0, "non-static method %s::%s() %s be called statically", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name), verb);
- if (severity != E_DEPRECATED) {
- retval = 0;
- }
- } else if (retval) {
- if (severity == E_ERROR) {
- zend_throw_error(NULL, "Non-static method %s::%s() %s be called statically", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name), verb);
- } else {
- zend_error(severity, "Non-static method %s::%s() %s be called statically", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name), verb);
- }
+ zend_spprintf(error, 0, "non-static method %s::%s() cannot be called statically", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name));
}
}
if (retval
@@ -3366,7 +3327,7 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam
{
zend_fcall_info_cache fcc;
- if (zend_is_callable_ex(callable, NULL, IS_CALLABLE_STRICT, callable_name, &fcc, NULL)) {
+ if (zend_is_callable_ex(callable, NULL, 0, callable_name, &fcc, NULL)) {
if (Z_TYPE_P(callable) == IS_STRING && fcc.calling_scope) {
zval_ptr_dtor_str(callable);
array_init(callable);