mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
I added the function/method name to some compile-time deprecation messages which are related to parameters/return values. Consistently with the other similar error messages, I included the function/method name at the start of the message.
This commit is contained in:
parent
0bc5cb625e
commit
2079da0158
24 changed files with 46 additions and 40 deletions
|
@ -7,6 +7,6 @@ class B { public function m(A $a = NULL, $n) { echo "B.m";} };
|
|||
class C extends B { public function m(A $a , $n) { echo "C.m";} };
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: B::m(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
|
||||
Fatal error: Declaration of C::m(A $a, $n) must be compatible with B::m(?A $a, $n) in %sbug71428.3.php on line 4
|
||||
|
|
|
@ -18,7 +18,7 @@ var_dump(call_user_func(array('foo', 'teste')));
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: {closure}(): Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in %s on line %d
|
||||
string(1) "x"
|
||||
array(1) {
|
||||
[0]=>
|
||||
|
|
|
@ -16,8 +16,8 @@ function c(
|
|||
) {}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: a(): Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in %s on line %d
|
||||
|
||||
Deprecated: Implicitly marking parameter $c as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: b(): Implicitly marking parameter $c as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
|
||||
Deprecated: Optional parameter $e declared before required parameter $f is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: c(): Optional parameter $e declared before required parameter $f is implicitly treated as a required parameter in %s on line %d
|
||||
|
|
|
@ -14,7 +14,7 @@ $x(new \stdclass);
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $x as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: foo\{closure}(): Implicitly marking parameter $x as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
NULL
|
||||
object(stdClass)#%d (0) {
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ function test3(Type $test3A = null, ?Type2 $test3B = null, $test3C) {}
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Optional parameter $testA declared before required parameter $testC is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: test(): Optional parameter $testA declared before required parameter $testC is implicitly treated as a required parameter in %s on line %d
|
||||
|
||||
Deprecated: Optional parameter $testB declared before required parameter $testC is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: test(): Optional parameter $testB declared before required parameter $testC is implicitly treated as a required parameter in %s on line %d
|
||||
|
||||
Deprecated: Implicitly marking parameter $test2A as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: test2(): Implicitly marking parameter $test2A as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
|
||||
Deprecated: Optional parameter $test2B declared before required parameter $test2C is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: test2(): Optional parameter $test2B declared before required parameter $test2C is implicitly treated as a required parameter in %s on line %d
|
||||
|
||||
Deprecated: Implicitly marking parameter $test3A as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: test3(): Implicitly marking parameter $test3A as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
|
||||
Deprecated: Optional parameter $test3B declared before required parameter $test3C is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: test3(): Optional parameter $test3B declared before required parameter $test3C is implicitly treated as a required parameter in %s on line %d
|
||||
|
|
|
@ -13,5 +13,5 @@ try {
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: test(): Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in %s on line %d
|
||||
test(): Argument #1 ($a) not passed
|
||||
|
|
|
@ -11,7 +11,7 @@ var_dump($r);
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Returning by reference from a void function is deprecated in %s on line %d
|
||||
Deprecated: test(): Returning by reference from a void function is deprecated in %s on line %d
|
||||
|
||||
Notice: Only variable references should be returned by reference in %s on line %d
|
||||
NULL
|
||||
|
|
|
@ -70,9 +70,9 @@ namespace HTML
|
|||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $attributes as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: HTML\Helper::attributes(): Implicitly marking parameter $attributes as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
|
||||
Deprecated: Implicitly marking parameter $attributes as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: HTML\TextArea::attributes(): Implicitly marking parameter $attributes as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
|
||||
Deprecated: Implicitly marking parameter $attributes as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: HTML\HTMLAttributes::attributes(): Implicitly marking parameter $attributes as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Done
|
||||
|
|
|
@ -14,7 +14,7 @@ foo("strpos", 123, "strpos");
|
|||
bar("substr");
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: bar(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
string(6) "strpos"
|
||||
int(123)
|
||||
string(6) "strpos"
|
||||
|
|
|
@ -11,5 +11,5 @@ foo(null);
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $foo as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: foo(): Implicitly marking parameter $foo as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
NULL
|
||||
|
|
|
@ -15,5 +15,5 @@ try {
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $foo as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: foo(): Implicitly marking parameter $foo as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
foo(): Argument #1 ($foo) must be of type (X&Y)|null, int given, called in %s on line %d
|
||||
|
|
|
@ -17,6 +17,6 @@ function baz(iterable $iterable = 1) {
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $iterable as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: foo(): Implicitly marking parameter $iterable as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
|
||||
Fatal error: Cannot use int as default value for parameter $iterable of type Traversable|array in %s on line %d
|
||||
|
|
|
@ -9,6 +9,6 @@ var_dump(test(false));
|
|||
var_dump(test(null));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $v as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: test(): Implicitly marking parameter $v as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
bool(false)
|
||||
NULL
|
||||
|
|
|
@ -9,6 +9,6 @@ var_dump(test(true));
|
|||
var_dump(test(null));
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $v as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: test(): Implicitly marking parameter $v as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
bool(true)
|
||||
NULL
|
||||
|
|
|
@ -8,5 +8,5 @@ function test(Foo $a = null) {
|
|||
test(null);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: test(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
ok
|
||||
|
|
|
@ -7126,7 +7126,9 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
|
|||
|
||||
if (ZEND_TYPE_CONTAINS_CODE(arg_infos[-1].type, IS_VOID)
|
||||
&& (op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE)) {
|
||||
zend_error(E_DEPRECATED, "Returning by reference from a void function is deprecated");
|
||||
zend_string *func_name = get_function_or_method_name((zend_function *) op_array);
|
||||
zend_error(E_DEPRECATED, "%s(): Returning by reference from a void function is deprecated", ZSTR_VAL(func_name));
|
||||
zend_string_release(func_name);
|
||||
}
|
||||
} else {
|
||||
if (list->children == 0) {
|
||||
|
@ -7225,9 +7227,11 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
|
|||
op_array->fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
|
||||
arg_info->type = zend_compile_typename_ex(type_ast, force_nullable, &forced_allow_nullable);
|
||||
if (forced_allow_nullable) {
|
||||
zend_string *func_name = get_function_or_method_name((zend_function *) op_array);
|
||||
zend_error(E_DEPRECATED,
|
||||
"Implicitly marking parameter $%s as nullable is deprecated, the explicit nullable type "
|
||||
"must be used instead", ZSTR_VAL(name));
|
||||
"%s(): Implicitly marking parameter $%s as nullable is deprecated, the explicit nullable type "
|
||||
"must be used instead", ZSTR_VAL(func_name), ZSTR_VAL(name));
|
||||
zend_string_release(func_name);
|
||||
}
|
||||
|
||||
if (ZEND_TYPE_FULL_MASK(arg_info->type) & MAY_BE_VOID) {
|
||||
|
@ -7253,11 +7257,13 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
|
|||
/* Ignore parameters of the form "Type $param = null".
|
||||
* This is the PHP 5 style way of writing "?Type $param", so allow it for now. */
|
||||
if (!forced_allow_nullable) {
|
||||
zend_string *func_name = get_function_or_method_name((zend_function *) op_array);
|
||||
zend_ast *required_param_ast = list->child[last_required_param];
|
||||
zend_error(E_DEPRECATED,
|
||||
"Optional parameter $%s declared before required parameter $%s "
|
||||
"%s(): Optional parameter $%s declared before required parameter $%s "
|
||||
"is implicitly treated as a required parameter",
|
||||
ZSTR_VAL(name), ZSTR_VAL(zend_ast_get_str(required_param_ast->child[1])));
|
||||
ZSTR_VAL(func_name), ZSTR_VAL(name), ZSTR_VAL(zend_ast_get_str(required_param_ast->child[1])));
|
||||
zend_string_release(func_name);
|
||||
}
|
||||
|
||||
/* Regardless of whether we issue a deprecation, convert this parameter into
|
||||
|
|
|
@ -20,7 +20,7 @@ define('K', "16 chars long --");
|
|||
echo new ReflectionClass("C"), "\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $h as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: A::pubf(): Implicitly marking parameter $h as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Class [ <user> class C extends A ] {
|
||||
@@ %s 14-14
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ foreach ($r->getParameters() as $p) {
|
|||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Optional parameter $a declared before required parameter $c is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: test(): Optional parameter $a declared before required parameter $c is implicitly treated as a required parameter in %s on line %d
|
||||
|
||||
Deprecated: Optional parameter $b declared before required parameter $c is implicitly treated as a required parameter in %s on line %d
|
||||
Deprecated: test(): Optional parameter $b declared before required parameter $c is implicitly treated as a required parameter in %s on line %d
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
|
|
|
@ -73,7 +73,7 @@ check_params(ReflectionMethod::createFromMethodName('test::method'));
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $opt as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: test(): Implicitly marking parameter $opt as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
#####test()#####
|
||||
===0===
|
||||
getName: string(3) "nix"
|
||||
|
|
|
@ -101,7 +101,7 @@ $r = (new ReflectionProperty($obj, 'std'))->getType();
|
|||
var_dump($r->getName());
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $d as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: foo(): Implicitly marking parameter $d as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
*** functions
|
||||
** Function 0 - Parameter 0
|
||||
bool(true)
|
||||
|
|
|
@ -25,7 +25,7 @@ dumpType((new ReflectionFunction('foo'))->getParameters()[0]->getType());
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $foo as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: foo(): Implicitly marking parameter $foo as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Type (X&Y)|null is ReflectionUnionType:
|
||||
Allows Null: true
|
||||
Type X&Y is ReflectionIntersectionType:
|
||||
|
|
|
@ -39,7 +39,7 @@ Test::f1(1);
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $ar as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: Test::f2(): Implicitly marking parameter $ar as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Test::f1()
|
||||
array(1) {
|
||||
[0]=>
|
||||
|
|
|
@ -143,11 +143,11 @@ Ensure type hints are enforced for functions invoked as callbacks.
|
|||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: f2(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
|
||||
Deprecated: Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: C::f2(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
|
||||
Deprecated: Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: D::f2(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
---> Type hints with callback function:
|
||||
0: f1(): Argument #1 ($a) must be of type A, int given%s(%d)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ $o->f();
|
|||
$o->f(NULL);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Implicitly marking parameter $p as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
Deprecated: T::f(): Implicitly marking parameter $p as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
|
||||
object(P)#2 (0) {
|
||||
}
|
||||
-
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue