Description
Description
The following code:
<?php
function testError($a, $b) {
print_r($a);
print_r($b);
sljdvsdjv();
}
function test() {
testError(
[1, 2, 3],
[4,5,6]
);
}
test();
which btw can be tested here: https://3v4l.org/E6MdJ
Resulted in this output:
Fatal error: Uncaught Error: Call to undefined function sljdvsdjv() in /in/E6MdJ:6
Stack trace:
#0 /in/E6MdJ(12): testError(Array, Array)
#1 /in/E6MdJ(16): test()
#2 {main}
thrown in /in/E6MdJ on line 6
But I expected this output instead:
Fatal error: Uncaught Error: Call to undefined function sljdvsdjv() in /in/E6MdJ:6
Stack trace:
#0 /in/E6MdJ(13): testError(Array, Array)
#1 /in/E6MdJ(16): test()
#2 {main}
thrown in /in/E6MdJ on line 6
Let's leave aside how the stacktrace is horribly messy and confusing.
Note the line number (12)
in #0
which should be (13)
.
That part of the stack trace refers to the call to testError()
from within test()
.
That call starts at line 10 (where the function name is) and ends at line 13, where the closing parenthesis )
is.
The meaningful line number for a function call is either where it starts or where it ends. Generally, the convention seems to be to mention the line number when it ends, for whatever reason.
But it ends in line 13, not 12. And this is not a matter of counting from 0 or a systematic offset of 1. It seems that php systematically reports the line number of where the end of the last argument to the function call is.
But it makes much more sense to place the end of a function call at the line where the closing parenthesis is. The former seems completely arbitrary.
PHP Version
PHP 8.1.8
Operating System
No response