]> granicus.if.org Git - php/commitdiff
Improve error message for deprecated methods
authorMáté Kocsis <kocsismate@woohoolabs.com>
Fri, 24 Apr 2020 08:58:10 +0000 (10:58 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Thu, 14 May 2020 15:23:31 +0000 (17:23 +0200)
14 files changed:
Zend/tests/bug69802_2.phpt
Zend/tests/bug78239.phpt
Zend/tests/type_declarations/callable_002.phpt
Zend/zend_execute.c
Zend/zend_execute.h
Zend/zend_execute_API.c
ext/opcache/jit/zend_jit_vm_helpers.c
ext/reflection/tests/ReflectionClass_isArray.phpt
ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt
ext/reflection/tests/bug26695.phpt
ext/reflection/tests/bug29268.phpt
ext/reflection/tests/bug39884.phpt
ext/reflection/tests/bug69802.phpt
ext/reflection/tests/parameters_002.phpt

index dca35a665cfdfc5d34ed225d86531e21d4285b90..63346f0afcb5c88968b633ed5aec7b25e6738def 100644 (file)
@@ -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"
index aa81af44520cd4aaabd642478fd26e566aadddf2..1ecad6746036a4d67acc29bd262d4141abf936c8 100644 (file)
@@ -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}
index f61955c706860d6af199fa6db94e5bc1a99702b4..ba47cf9ae5c3905d38a06b698aaae871a4fce3be 100644 (file)
@@ -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)
index 35e3691a4c8e3e762ca3ca1751990822d6595395..2eb7b1726010c99db858eb8a8330de35720c3b0d 100644 (file)
@@ -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)
index 5dbc2ad11dabf4185efb7be437af804536db04bd..2299adf62fe7ee4832e0e865fb8863137538ebac 100644 (file)
@@ -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);
index 0c3917163d80d805c71ce20e7e6e6af25e9fac04..0a7a7e3b15cecf8edca0e54c0b2c2a1030169bdc 100644 (file)
@@ -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) {
index c766aaaadda428d3d8d82208bb64ef1a943aab99..4a15dca129e4fd5a24903d815624adb000f1a80d 100644 (file)
@@ -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);
index 4166ae71cc954381c62bc8f2842ae9864e134dbc..67df4e98e75427739a1b258bd53fbe0edb1b9c85 100644 (file)
@@ -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)
index d63492751655eeebadb6541138067a0b7698eecf..9cc7eaa31f0faa1db073aa77d762f496a416d25f 100644 (file)
@@ -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)
index 66766c5ebb21984f6319946aacb9e894f0d47aa8..2f50e2151ca08ef3f09ad3e4f215ec4583ac0e33 100644 (file)
@@ -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"
index f46829be9751ab42d8dd47779b103ac4b1bc78dd..4bb12819bc512e085e54b04ab949cbdf212addad 100644 (file)
@@ -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
index 6e73066bd44c66d4af56ebb14967866d3c659696..40494930289b6bb719fa98d5a896ee2f6a87d7a5 100644 (file)
@@ -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"
index 35a0f991fa920ceaf74463cdad5979d7fbee5d74..bf60ea0143694cadb0f4c3e12dfe378951720845 100644 (file)
@@ -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"
index f4a7ca19c6b46f6ac1c3d2b9a2f1009d3a1bfcb1..e25310a6c790d1d15341de3c92abcc0442c5d782 100644 (file)
@@ -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)