Skip to content

Commit 9975986

Browse files
committed
Improve error messages mentioning parameters instead of arguments
Closes GH-5999
1 parent c5b42be commit 9975986

File tree

143 files changed

+473
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+473
-452
lines changed

UPGRADING

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ PHP 8.0 UPGRADE NOTES
135135
. Uncaught exceptions now go through "clean shutdown", which means that
136136
destructors will be called after an uncaught exception.
137137
. Compile time fatal error "Only variables can be passed by reference" has
138-
been delayed until runtime and converted to "Cannot pass parameter by
138+
been delayed until runtime and converted to "Argument cannot be passed by
139139
reference" exception.
140140
. Some "Only variables should be passed by reference" notices have been
141-
converted to "Cannot pass parameter by reference" exception.
141+
converted to "Argument cannot be passed by reference" exception.
142142
. The generated name for anonymous classes has changed. It will now include
143143
the name of the first parent or interface:
144144

Zend/tests/bug46106.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ try {
2323
?>
2424
DONE
2525
--EXPECT--
26-
str_pad() expects at least 2 parameters, 1 given
26+
str_pad() expects at least 2 arguments, 1 given
2727
DONE

Zend/tests/bug51827.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ register_shutdown_function('exploDe');
1616
--EXPECT--
1717
int(1)
1818

19-
Fatal error: Uncaught ArgumentCountError: explode() expects at least 2 parameters, 0 given in [no active file]:0
19+
Fatal error: Uncaught ArgumentCountError: explode() expects at least 2 arguments, 0 given in [no active file]:0
2020
Stack trace:
2121
#0 [internal function]: explode()
2222
#1 {main}

Zend/tests/bug72038.phpt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,25 @@ Bug #72038 (Function calls with values to a by-ref parameter don't always throw
66
try {
77
test($foo = new stdClass);
88
var_dump($foo);
9-
} catch (Throwable $e) {
10-
echo "Exception: " . $e->getMessage() . "\n";
9+
} catch (Error $e) {
10+
echo $e->getMessage() . "\n";
1111
}
1212
try {
1313
test($bar = 2);
1414
var_dump($bar);
15-
} catch (Throwable $e) {
16-
echo "Exception: " . $e->getMessage() . "\n";
17-
}
18-
try {
19-
test($baz = &$bar);
20-
var_dump($baz);
21-
} catch (Throwable $e) {
22-
echo "Exception: " . $e->getMessage() . "\n";
15+
} catch (Error $e) {
16+
echo $e->getMessage() . "\n";
2317
}
2418

19+
test($baz = &$bar);
20+
var_dump($baz);
21+
2522
function test(&$param) {
2623
$param = 1;
2724
}
2825

2926
?>
3027
--EXPECT--
31-
Exception: Cannot pass parameter 1 by reference
32-
Exception: Cannot pass parameter 1 by reference
28+
test(): Argument #1 ($param) cannot be passed by reference
29+
test(): Argument #1 ($param) cannot be passed by reference
3330
int(1)

Zend/tests/bug72107.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ try {
1313
}
1414
?>
1515
--EXPECT--
16-
func_get_args() expects exactly 0 parameters, 4 given
16+
func_get_args() expects exactly 0 arguments, 4 given

Zend/tests/bug73663_2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ change(list($val) = $array);
1212
var_dump($array);
1313
?>
1414
--EXPECTF--
15-
Fatal error: Uncaught Error: Cannot pass parameter 1 by reference in %s:%d
15+
Fatal error: Uncaught Error: change(): Argument #1 ($ref) cannot be passed by reference in %s:%d
1616
Stack trace:
1717
#0 {main}
1818
thrown in %s on line %d

Zend/tests/bug78154.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ namespace Foo {
2222

2323
?>
2424
--EXPECT--
25-
Exception: Cannot pass parameter 3 by reference
26-
Exception: Cannot pass parameter 3 by reference
25+
Exception: similar_text(): Argument #3 ($percent) cannot be passed by reference
26+
Exception: similar_text(): Argument #3 ($percent) cannot be passed by reference

Zend/tests/bug79783.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Bug #79783: Segfault in php_str_replace_common
55
str_replace("a", "b", "c", strlen("d"));
66
?>
77
--EXPECTF--
8-
Fatal error: Uncaught Error: Cannot pass parameter 4 by reference in %s:%d
8+
Fatal error: Uncaught Error: str_replace(): Argument #4 ($replace_count) cannot be passed by reference in %s:%d
99
Stack trace:
1010
#0 {main}
1111
thrown in %s on line %d

Zend/tests/closure_019.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int(9)
2626
Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
2727
int(81)
2828

29-
Fatal error: Uncaught Error: Cannot pass parameter 1 by reference in %s:%d
29+
Fatal error: Uncaught Error: {closure}(): Argument #1 ($x) cannot be passed by reference in %s:%d
3030
Stack trace:
3131
#0 %s(%d): test()
3232
#1 {main}

Zend/tests/errmsg_022.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ foo(1);
1111
echo "Done\n";
1212
?>
1313
--EXPECTF--
14-
Fatal error: Uncaught Error: Cannot pass parameter 1 by reference in %s:%d
14+
Fatal error: Uncaught Error: foo(): Argument #1 ($var) cannot be passed by reference in %s:%d
1515
Stack trace:
1616
#0 {main}
1717
thrown in %s on line %d

0 commit comments

Comments
 (0)