summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-04-24 10:58:10 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-05-14 17:23:31 +0200
commit93640db4d5ca4e41079577a03cf969fa6c63d533 (patch)
tree62062db09fc295b66a5d7dca3f1254406306af3f /Zend
parent4bc1cf29287fd73ced0f93f713fe93e421465cd7 (diff)
downloadphp-git-93640db4d5ca4e41079577a03cf969fa6c63d533.tar.gz
Improve error message for deprecated methods
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/bug69802_2.phpt2
-rw-r--r--Zend/tests/bug78239.phpt2
-rw-r--r--Zend/tests/type_declarations/callable_002.phpt6
-rw-r--r--Zend/zend_execute.c14
-rw-r--r--Zend/zend_execute.h1
-rw-r--r--Zend/zend_execute_API.c6
6 files changed, 17 insertions, 14 deletions
diff --git a/Zend/tests/bug69802_2.phpt b/Zend/tests/bug69802_2.phpt
index dca35a665c..63346f0afc 100644
--- a/Zend/tests/bug69802_2.phpt
+++ b/Zend/tests/bug69802_2.phpt
@@ -7,7 +7,7 @@ $r = new ReflectionMethod($f, '__invoke');
var_dump($r->getParameters()[0]->getClass());
?>
--EXPECTF--
-Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
+Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
object(ReflectionClass)#4 (1) {
["name"]=>
string(11) "Traversable"
diff --git a/Zend/tests/bug78239.phpt b/Zend/tests/bug78239.phpt
index aa81af4452..1ecad67460 100644
--- a/Zend/tests/bug78239.phpt
+++ b/Zend/tests/bug78239.phpt
@@ -16,7 +16,7 @@ $r = new _ZendTestClass;
?>
--EXPECTF--
-Fatal error: Uncaught ErrorException: Function _ZendTestClass::__toString() is deprecated in %s:%d
+Fatal error: Uncaught ErrorException: Method _ZendTestClass::__toString() is deprecated in %s:%d
Stack trace:
#0 %s(%d): handleError(%s)
#1 {main}
diff --git a/Zend/tests/type_declarations/callable_002.phpt b/Zend/tests/type_declarations/callable_002.phpt
index f61955c706..ba47cf9ae5 100644
--- a/Zend/tests/type_declarations/callable_002.phpt
+++ b/Zend/tests/type_declarations/callable_002.phpt
@@ -21,11 +21,11 @@ var_dump($rc->getParameters()[0]->isCallable());
?>
--EXPECTF--
-Deprecated: Function ReflectionParameter::isCallable() is deprecated in %s on line %d
+Deprecated: Method ReflectionParameter::isCallable() is deprecated in %s on line %d
bool(true)
-Deprecated: Function ReflectionParameter::isCallable() is deprecated in %s on line %d
+Deprecated: Method ReflectionParameter::isCallable() is deprecated in %s on line %d
bool(true)
-Deprecated: Function ReflectionParameter::isCallable() is deprecated in %s on line %d
+Deprecated: Method ReflectionParameter::isCallable() is deprecated in %s on line %d
bool(true)
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 35e3691a4c..2eb7b17260 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1502,12 +1502,16 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_wrong_property_read(z
zend_tmp_string_release(tmp_property_name);
}
-static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc)
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc)
{
- zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
- fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
- fbc->common.scope ? "::" : "",
- ZSTR_VAL(fbc->common.function_name));
+ if (fbc->common.scope) {
+ zend_error(E_DEPRECATED, "Method %s::%s() is deprecated",
+ ZSTR_VAL(fbc->common.scope->name),
+ ZSTR_VAL(fbc->common.function_name)
+ );
+ } else {
+ zend_error(E_DEPRECATED, "Function %s() is deprecated", ZSTR_VAL(fbc->common.function_name));
+ }
}
static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim, zval *value OPLINE_DC EXECUTE_DATA_DC)
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index 5dbc2ad11d..2299adf62f 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -53,6 +53,7 @@ ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_
extern ZEND_API const zend_internal_function zend_pass_function;
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_missing_arg_error(zend_execute_data *execute_data);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc);
ZEND_API zend_bool ZEND_FASTCALL zend_verify_ref_assignable_zval(zend_reference *ref, zval *zv, zend_bool strict);
ZEND_API zend_bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref(zend_property_info *prop_info, zval *orig_val, zend_bool strict);
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 0c3917163d..0a7a7e3b15 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -722,10 +722,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
func, fci->param_count, object_or_called_scope);
if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_DEPRECATED)) {
- zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
- func->common.scope ? ZSTR_VAL(func->common.scope->name) : "",
- func->common.scope ? "::" : "",
- ZSTR_VAL(func->common.function_name));
+ zend_deprecated_function(func);
+
if (UNEXPECTED(EG(exception))) {
zend_vm_stack_free_call_frame(call);
if (EG(current_execute_data) == &dummy_execute_data) {