Skip to content

Commit 93640db

Browse files
committed
Improve error message for deprecated methods
1 parent 4bc1cf2 commit 93640db

14 files changed

+57
-55
lines changed

Zend/tests/bug69802_2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $r = new ReflectionMethod($f, '__invoke');
77
var_dump($r->getParameters()[0]->getClass());
88
?>
99
--EXPECTF--
10-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
10+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
1111
object(ReflectionClass)#4 (1) {
1212
["name"]=>
1313
string(11) "Traversable"

Zend/tests/bug78239.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $r = new _ZendTestClass;
1616

1717
?>
1818
--EXPECTF--
19-
Fatal error: Uncaught ErrorException: Function _ZendTestClass::__toString() is deprecated in %s:%d
19+
Fatal error: Uncaught ErrorException: Method _ZendTestClass::__toString() is deprecated in %s:%d
2020
Stack trace:
2121
#0 %s(%d): handleError(%s)
2222
#1 {main}

Zend/tests/type_declarations/callable_002.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ var_dump($rc->getParameters()[0]->isCallable());
2121

2222
?>
2323
--EXPECTF--
24-
Deprecated: Function ReflectionParameter::isCallable() is deprecated in %s on line %d
24+
Deprecated: Method ReflectionParameter::isCallable() is deprecated in %s on line %d
2525
bool(true)
2626

27-
Deprecated: Function ReflectionParameter::isCallable() is deprecated in %s on line %d
27+
Deprecated: Method ReflectionParameter::isCallable() is deprecated in %s on line %d
2828
bool(true)
2929

30-
Deprecated: Function ReflectionParameter::isCallable() is deprecated in %s on line %d
30+
Deprecated: Method ReflectionParameter::isCallable() is deprecated in %s on line %d
3131
bool(true)

Zend/zend_execute.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,12 +1502,16 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_wrong_property_read(z
15021502
zend_tmp_string_release(tmp_property_name);
15031503
}
15041504

1505-
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc)
1505+
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc)
15061506
{
1507-
zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
1508-
fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
1509-
fbc->common.scope ? "::" : "",
1510-
ZSTR_VAL(fbc->common.function_name));
1507+
if (fbc->common.scope) {
1508+
zend_error(E_DEPRECATED, "Method %s::%s() is deprecated",
1509+
ZSTR_VAL(fbc->common.scope->name),
1510+
ZSTR_VAL(fbc->common.function_name)
1511+
);
1512+
} else {
1513+
zend_error(E_DEPRECATED, "Function %s() is deprecated", ZSTR_VAL(fbc->common.function_name));
1514+
}
15111515
}
15121516

15131517
static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim, zval *value OPLINE_DC EXECUTE_DATA_DC)

Zend/zend_execute.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_
5353
extern ZEND_API const zend_internal_function zend_pass_function;
5454

5555
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_missing_arg_error(zend_execute_data *execute_data);
56+
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc);
5657

5758
ZEND_API zend_bool ZEND_FASTCALL zend_verify_ref_assignable_zval(zend_reference *ref, zval *zv, zend_bool strict);
5859
ZEND_API zend_bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref(zend_property_info *prop_info, zval *orig_val, zend_bool strict);

Zend/zend_execute_API.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
722722
func, fci->param_count, object_or_called_scope);
723723

724724
if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_DEPRECATED)) {
725-
zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
726-
func->common.scope ? ZSTR_VAL(func->common.scope->name) : "",
727-
func->common.scope ? "::" : "",
728-
ZSTR_VAL(func->common.function_name));
725+
zend_deprecated_function(func);
726+
729727
if (UNEXPECTED(EG(exception))) {
730728
zend_vm_stack_free_call_frame(call);
731729
if (EG(current_execute_data) == &dummy_execute_data) {

ext/opcache/jit/zend_jit_vm_helpers.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,9 @@ void ZEND_FASTCALL zend_jit_deprecated_helper(OPLINE_D)
157157
{
158158
zend_execute_data *call = (zend_execute_data *) opline;
159159
zend_function *fbc = call->func;
160-
zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
161-
fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
162-
fbc->common.scope ? "::" : "",
163-
ZSTR_VAL(fbc->common.function_name));
160+
161+
zend_deprecated_function(fbc);
162+
164163
if (EG(exception)) {
165164
#ifndef HAVE_GCC_GLOBAL_REGS
166165
zend_execute_data *execute_data = EG(current_execute_data);

ext/reflection/tests/ReflectionClass_isArray.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ foreach ($reflection->getParameters() as $parameter) {
1414
}
1515
?>
1616
--EXPECTF--
17-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
17+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
1818
bool(true)
1919

20-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
20+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
2121
bool(true)
2222

23-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
23+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
2424
bool(false)
2525

26-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
26+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
2727
bool(false)

ext/reflection/tests/ReflectionFunction_isDisabled_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ var_dump($rf->isDisabled());
2020
--EXPECTF--
2121
Function is_file() does not exist
2222

23-
Deprecated: Function ReflectionFunction::isDisabled() is deprecated in %s on line %d
23+
Deprecated: Method ReflectionFunction::isDisabled() is deprecated in %s on line %d
2424
bool(false)

ext/reflection/tests/bug26695.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ $class = $params[0]->getClass();
2020
var_dump($class->getName());
2121
?>
2222
--EXPECTF--
23-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
23+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
2424
string(3) "Foo"

ext/reflection/tests/bug29268.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ foreach($parameters as $parameter)
2222
echo "ok\n";
2323
?>
2424
--EXPECTF--
25-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
25+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
2626
__autoload(A)
2727
A
2828
ok

ext/reflection/tests/bug39884.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $refParam = new ReflectionParameter(array('stubParamTest', 'paramTest'), 'param'
1616
var_dump($refParam->getClass());
1717
?>
1818
--EXPECTF--
19-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
19+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
2020
object(ReflectionClass)#4 (1) {
2121
["name"]=>
2222
string(13) "stubParamTest"

ext/reflection/tests/bug69802.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ echo $r,"\n";
1313
--EXPECTF--
1414
string(1) "x"
1515

16-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
16+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
1717
object(ReflectionClass)#4 (1) {
1818
["name"]=>
1919
string(8) "stdClass"

ext/reflection/tests/parameters_002.phpt

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ check_params(new ReflectionMethod('test::method'));
7878
getName: string(3) "nix"
7979
isPassedByReference: bool(false)
8080

81-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
81+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
8282
getClass: NULL
8383
getDeclaringClass: NULL
8484
isArray:
85-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
85+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
8686
bool(false)
8787
allowsNull: bool(true)
8888
isOptional: bool(false)
@@ -91,11 +91,11 @@ isDefaultValueAvailable: bool(false)
9191
getName: string(2) "ar"
9292
isPassedByReference: bool(false)
9393

94-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
94+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
9595
getClass: NULL
9696
getDeclaringClass: NULL
9797
isArray:
98-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
98+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
9999
bool(true)
100100
allowsNull: bool(false)
101101
isOptional: bool(false)
@@ -104,11 +104,11 @@ isDefaultValueAvailable: bool(false)
104104
getName: string(3) "ref"
105105
isPassedByReference: bool(true)
106106

107-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
107+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
108108
getClass: NULL
109109
getDeclaringClass: NULL
110110
isArray:
111-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
111+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
112112
bool(false)
113113
allowsNull: bool(true)
114114
isOptional: bool(false)
@@ -117,11 +117,11 @@ isDefaultValueAvailable: bool(false)
117117
getName: string(3) "std"
118118
isPassedByReference: bool(false)
119119

120-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
120+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
121121
getClass: stdClass
122122
getDeclaringClass: NULL
123123
isArray:
124-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
124+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
125125
bool(false)
126126
allowsNull: bool(false)
127127
isOptional: bool(false)
@@ -130,11 +130,11 @@ isDefaultValueAvailable: bool(false)
130130
getName: string(2) "na"
131131
isPassedByReference: bool(false)
132132

133-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
133+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
134134
Class NonExistingClass does not exist
135135
getDeclaringClass: NULL
136136
isArray:
137-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
137+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
138138
bool(false)
139139
allowsNull: bool(false)
140140
isOptional: bool(false)
@@ -143,11 +143,11 @@ isDefaultValueAvailable: bool(false)
143143
getName: string(3) "opt"
144144
isPassedByReference: bool(true)
145145

146-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
146+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
147147
getClass: stdClass
148148
getDeclaringClass: NULL
149149
isArray:
150-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
150+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
151151
bool(false)
152152
allowsNull: bool(true)
153153
isOptional: bool(true)
@@ -157,11 +157,11 @@ getDefaultValue: NULL
157157
getName: string(3) "def"
158158
isPassedByReference: bool(false)
159159

160-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
160+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
161161
getClass: NULL
162162
getDeclaringClass: NULL
163163
isArray:
164-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
164+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
165165
bool(false)
166166
allowsNull: bool(true)
167167
isOptional: bool(true)
@@ -172,11 +172,11 @@ getDefaultValue: string(6) "FooBar"
172172
getName: string(3) "nix"
173173
isPassedByReference: bool(false)
174174

175-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
175+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
176176
getClass: NULL
177177
getDeclaringClass: test
178178
isArray:
179-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
179+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
180180
bool(false)
181181
allowsNull: bool(true)
182182
isOptional: bool(false)
@@ -185,11 +185,11 @@ isDefaultValueAvailable: bool(false)
185185
getName: string(2) "ar"
186186
isPassedByReference: bool(false)
187187

188-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
188+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
189189
getClass: NULL
190190
getDeclaringClass: test
191191
isArray:
192-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
192+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
193193
bool(true)
194194
allowsNull: bool(false)
195195
isOptional: bool(false)
@@ -198,11 +198,11 @@ isDefaultValueAvailable: bool(false)
198198
getName: string(3) "ref"
199199
isPassedByReference: bool(true)
200200

201-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
201+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
202202
getClass: NULL
203203
getDeclaringClass: test
204204
isArray:
205-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
205+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
206206
bool(false)
207207
allowsNull: bool(true)
208208
isOptional: bool(false)
@@ -211,11 +211,11 @@ isDefaultValueAvailable: bool(false)
211211
getName: string(3) "std"
212212
isPassedByReference: bool(false)
213213

214-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
214+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
215215
getClass: stdClass
216216
getDeclaringClass: test
217217
isArray:
218-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
218+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
219219
bool(false)
220220
allowsNull: bool(false)
221221
isOptional: bool(false)
@@ -224,11 +224,11 @@ isDefaultValueAvailable: bool(false)
224224
getName: string(2) "na"
225225
isPassedByReference: bool(false)
226226

227-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
227+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
228228
Class NonExistingClass does not exist
229229
getDeclaringClass: test
230230
isArray:
231-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
231+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
232232
bool(false)
233233
allowsNull: bool(false)
234234
isOptional: bool(false)
@@ -237,11 +237,11 @@ isDefaultValueAvailable: bool(false)
237237
getName: string(3) "opt"
238238
isPassedByReference: bool(false)
239239

240-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
240+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
241241
getClass: stdClass
242242
getDeclaringClass: test
243243
isArray:
244-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
244+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
245245
bool(false)
246246
allowsNull: bool(true)
247247
isOptional: bool(true)
@@ -251,11 +251,11 @@ getDefaultValue: NULL
251251
getName: string(3) "def"
252252
isPassedByReference: bool(false)
253253

254-
Deprecated: Function ReflectionParameter::getClass() is deprecated in %s on line %d
254+
Deprecated: Method ReflectionParameter::getClass() is deprecated in %s on line %d
255255
getClass: NULL
256256
getDeclaringClass: test
257257
isArray:
258-
Deprecated: Function ReflectionParameter::isArray() is deprecated in %s on line %d
258+
Deprecated: Method ReflectionParameter::isArray() is deprecated in %s on line %d
259259
bool(false)
260260
allowsNull: bool(true)
261261
isOptional: bool(true)

0 commit comments

Comments
 (0)