diff options
author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-04-24 10:58:10 +0200 |
---|---|---|
committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-05-14 17:23:31 +0200 |
commit | 93640db4d5ca4e41079577a03cf969fa6c63d533 (patch) | |
tree | 62062db09fc295b66a5d7dca3f1254406306af3f | |
parent | 4bc1cf29287fd73ced0f93f713fe93e421465cd7 (diff) | |
download | php-git-93640db4d5ca4e41079577a03cf969fa6c63d533.tar.gz |
Improve error message for deprecated methods
-rw-r--r-- | Zend/tests/bug69802_2.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/bug78239.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/type_declarations/callable_002.phpt | 6 | ||||
-rw-r--r-- | Zend/zend_execute.c | 14 | ||||
-rw-r--r-- | Zend/zend_execute.h | 1 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 6 | ||||
-rw-r--r-- | ext/opcache/jit/zend_jit_vm_helpers.c | 7 | ||||
-rw-r--r-- | ext/reflection/tests/ReflectionClass_isArray.phpt | 8 | ||||
-rw-r--r-- | ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt | 2 | ||||
-rw-r--r-- | ext/reflection/tests/bug26695.phpt | 2 | ||||
-rw-r--r-- | ext/reflection/tests/bug29268.phpt | 2 | ||||
-rw-r--r-- | ext/reflection/tests/bug39884.phpt | 2 | ||||
-rw-r--r-- | ext/reflection/tests/bug69802.phpt | 2 | ||||
-rw-r--r-- | ext/reflection/tests/parameters_002.phpt | 56 |
14 files changed, 57 insertions, 55 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) { diff --git a/ext/opcache/jit/zend_jit_vm_helpers.c b/ext/opcache/jit/zend_jit_vm_helpers.c index c766aaaadd..4a15dca129 100644 --- a/ext/opcache/jit/zend_jit_vm_helpers.c +++ b/ext/opcache/jit/zend_jit_vm_helpers.c @@ -157,10 +157,9 @@ void ZEND_FASTCALL zend_jit_deprecated_helper(OPLINE_D) { zend_execute_data *call = (zend_execute_data *) opline; zend_function *fbc = call->func; - 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)); + + zend_deprecated_function(fbc); + if (EG(exception)) { #ifndef HAVE_GCC_GLOBAL_REGS zend_execute_data *execute_data = EG(current_execute_data); diff --git a/ext/reflection/tests/ReflectionClass_isArray.phpt b/ext/reflection/tests/ReflectionClass_isArray.phpt index 4166ae71cc..67df4e98e7 100644 --- a/ext/reflection/tests/ReflectionClass_isArray.phpt +++ b/ext/reflection/tests/ReflectionClass_isArray.phpt @@ -14,14 +14,14 @@ foreach ($reflection->getParameters() as $parameter) { } ?> --EXPECTF-- -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(true) -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(true) -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) diff --git a/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt index d634927516..9cc7eaa31f 100644 --- a/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt +++ b/ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt @@ -20,5 +20,5 @@ var_dump($rf->isDisabled()); --EXPECTF-- Function is_file() does not exist -Deprecated: Function ReflectionFunction::isDisabled() is deprecated in %s on line %d +Deprecated: Method ReflectionFunction::isDisabled() is deprecated in %s on line %d bool(false) diff --git a/ext/reflection/tests/bug26695.phpt b/ext/reflection/tests/bug26695.phpt index 66766c5ebb..2f50e2151c 100644 --- a/ext/reflection/tests/bug26695.phpt +++ b/ext/reflection/tests/bug26695.phpt @@ -20,5 +20,5 @@ $class = $params[0]->getClass(); var_dump($class->getName()); ?> --EXPECTF-- -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d string(3) "Foo" diff --git a/ext/reflection/tests/bug29268.phpt b/ext/reflection/tests/bug29268.phpt index f46829be97..4bb12819bc 100644 --- a/ext/reflection/tests/bug29268.phpt +++ b/ext/reflection/tests/bug29268.phpt @@ -22,7 +22,7 @@ foreach($parameters as $parameter) echo "ok\n"; ?> --EXPECTF-- -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d __autoload(A) A ok diff --git a/ext/reflection/tests/bug39884.phpt b/ext/reflection/tests/bug39884.phpt index 6e73066bd4..4049493028 100644 --- a/ext/reflection/tests/bug39884.phpt +++ b/ext/reflection/tests/bug39884.phpt @@ -16,7 +16,7 @@ $refParam = new ReflectionParameter(array('stubParamTest', 'paramTest'), 'param' var_dump($refParam->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(13) "stubParamTest" diff --git a/ext/reflection/tests/bug69802.phpt b/ext/reflection/tests/bug69802.phpt index 35a0f991fa..bf60ea0143 100644 --- a/ext/reflection/tests/bug69802.phpt +++ b/ext/reflection/tests/bug69802.phpt @@ -13,7 +13,7 @@ echo $r,"\n"; --EXPECTF-- string(1) "x" -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(8) "stdClass" diff --git a/ext/reflection/tests/parameters_002.phpt b/ext/reflection/tests/parameters_002.phpt index f4a7ca19c6..e25310a6c7 100644 --- a/ext/reflection/tests/parameters_002.phpt +++ b/ext/reflection/tests/parameters_002.phpt @@ -78,11 +78,11 @@ check_params(new ReflectionMethod('test::method')); getName: string(3) "nix" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: NULL getDeclaringClass: NULL isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(true) isOptional: bool(false) @@ -91,11 +91,11 @@ isDefaultValueAvailable: bool(false) getName: string(2) "ar" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: NULL getDeclaringClass: NULL isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(true) allowsNull: bool(false) isOptional: bool(false) @@ -104,11 +104,11 @@ isDefaultValueAvailable: bool(false) getName: string(3) "ref" isPassedByReference: bool(true) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: NULL getDeclaringClass: NULL isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(true) isOptional: bool(false) @@ -117,11 +117,11 @@ isDefaultValueAvailable: bool(false) getName: string(3) "std" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: stdClass getDeclaringClass: NULL isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(false) isOptional: bool(false) @@ -130,11 +130,11 @@ isDefaultValueAvailable: bool(false) getName: string(2) "na" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d Class NonExistingClass does not exist getDeclaringClass: NULL isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(false) isOptional: bool(false) @@ -143,11 +143,11 @@ isDefaultValueAvailable: bool(false) getName: string(3) "opt" isPassedByReference: bool(true) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: stdClass getDeclaringClass: NULL isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(true) isOptional: bool(true) @@ -157,11 +157,11 @@ getDefaultValue: NULL getName: string(3) "def" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: NULL getDeclaringClass: NULL isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(true) isOptional: bool(true) @@ -172,11 +172,11 @@ getDefaultValue: string(6) "FooBar" getName: string(3) "nix" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: NULL getDeclaringClass: test isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(true) isOptional: bool(false) @@ -185,11 +185,11 @@ isDefaultValueAvailable: bool(false) getName: string(2) "ar" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: NULL getDeclaringClass: test isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(true) allowsNull: bool(false) isOptional: bool(false) @@ -198,11 +198,11 @@ isDefaultValueAvailable: bool(false) getName: string(3) "ref" isPassedByReference: bool(true) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: NULL getDeclaringClass: test isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(true) isOptional: bool(false) @@ -211,11 +211,11 @@ isDefaultValueAvailable: bool(false) getName: string(3) "std" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: stdClass getDeclaringClass: test isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(false) isOptional: bool(false) @@ -224,11 +224,11 @@ isDefaultValueAvailable: bool(false) getName: string(2) "na" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d Class NonExistingClass does not exist getDeclaringClass: test isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(false) isOptional: bool(false) @@ -237,11 +237,11 @@ isDefaultValueAvailable: bool(false) getName: string(3) "opt" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: stdClass getDeclaringClass: test isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(true) isOptional: bool(true) @@ -251,11 +251,11 @@ getDefaultValue: NULL getName: string(3) "def" isPassedByReference: bool(false) -Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d getClass: NULL getDeclaringClass: test isArray: -Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d +Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d bool(false) allowsNull: bool(true) isOptional: bool(true) |