[PHP-DEV] Displaying function arguments in errors

Hi internals,

I'm dusting off an old PR (GH-12276) I had that I had lying around that
I think would be quite useful.

Currently, errors in PHP can optionally return some parameter info in
the docref call; in practice, few do so, except a few functions.
This means if you're looking at a PHP error log, you can see what
function is failing, but often not why without having to step debug it.

What this PR will do is effectively turn this:

Warning: unlink('/tmp'): Operation not permitted in /Users/calvin/src/chmod.php on line 3

Warning: chown('/', 'calvin'): Operation not permitted in /Users/calvin/src/chmod.php on line 4

Warning: chmod('/', 511): Operation not permitted in /Users/calvin/src/chmod.php on line 5

Into this:

Warning: unlink(/tmp): Operation not permitted in /Users/calvin/src/chmod.php on line 3

Warning: chown(): Operation not permitted in /Users/calvin/src/chmod.php on line 4

Warning: chmod(): Operation not permitted in /Users/calvin/src/chmod.php on line 5

This should make it easier at a glance to see what goes wrong in a log.
Because this reuses the current infrastructure for stack traces, this
will also handle i.e. sensitive parameters for free.

Because this may not always be desirable (i.e. log size, logging PII
that wasn't tagged as sensitive, not having to rewrite every .phpt
file), this will be an INI option. We can vote on what should be the
defaults, and what should be done with tests. Note that the docref's
parameter will be displayed if it's turned off (or i.e. out of memory).

I think this will almost certainly need an RFC; if there's interest,
I'll start working on that.

Regards,
Calvin

PR is at: Aggressively use actual function parameters in `php_verror` by NattyNarwhal · Pull Request #12276 · php/php-src · GitHub

Hi

Am 2026-03-04 20:24, schrieb Calvin Buckley:

What this PR will do is effectively turn this:

Warning: unlink('/tmp'): Operation not permitted in /Users/calvin/src/chmod.php on line 3

Warning: chown('/', 'calvin'): Operation not permitted in /Users/calvin/src/chmod.php on line 4

Warning: chmod('/', 511): Operation not permitted in /Users/calvin/src/chmod.php on line 5

Into this:

Warning: unlink(/tmp): Operation not permitted in /Users/calvin/src/chmod.php on line 3

Warning: chown(): Operation not permitted in /Users/calvin/src/chmod.php on line 4

Warning: chmod(): Operation not permitted in /Users/calvin/src/chmod.php on line 5

Did you mix up the two code blocks? I suspect the first block block is the “New” output and the second one the “Old” output?

Best regards
Tim Düsterhus

I'm dusting off an old PR (GH-12276) I had that I had lying around that
I think would be quite useful.

Currently, errors in PHP can optionally return some parameter info in
the docref call; in practice, few do so, except a few functions.
This means if you're looking at a PHP error log, you can see what
function is failing, but often not why without having to step debug it.

What this PR will do is effectively turn this:

Warning: unlink('/tmp'): Operation not permitted in /Users/calvin/src/chmod.php on line 3

Warning: chown('/', 'calvin'): Operation not permitted in /Users/calvin/src/chmod.php on line 4

Warning: chmod('/', 511): Operation not permitted in /Users/calvin/src/chmod.php on line 5

Into this:

Warning: unlink(/tmp): Operation not permitted in /Users/calvin/src/chmod.php on line 3

Warning: chown(): Operation not permitted in /Users/calvin/src/chmod.php on line 4

Warning: chmod(): Operation not permitted in /Users/calvin/src/chmod.php on line 5

This should make it easier at a glance to see what goes wrong in a log.
Because this reuses the current infrastructure for stack traces, this
will also handle i.e. sensitive parameters for free.

Because this may not always be desirable (i.e. log size, logging PII
that wasn't tagged as sensitive, not having to rewrite every .phpt
file), this will be an INI option. We can vote on what should be the
defaults, and what should be done with tests. Note that the docref's
parameter will be displayed if it's turned off (or i.e. out of memory).

I think this will almost certainly need an RFC; if there's interest,
I'll start working on that.

Regards,
Calvin

PR is at: Aggressively use actual function parameters in `php_verror` by NattyNarwhal · Pull Request #12276 · php/php-src · GitHub

Hi Calvin,
I'm glad you are reviving that PR. I think this will be a nice improvement.

I was worried that large parameters might pollute the error logs. I
tested the PR, and it was a pleasant surprise that the parameters
shown in the warning message also follow
`zend.exception_string_param_max_len` INI setting and get trimmed to
that length.

In the RFC, you might also want to mention in the PR that the
parameters will be trimmed (just like SensitiveParameters are masked),
and code like this will not write the whole parameter to the error
log:

ini_set('display_error_function_args', '1');
file_put_contents('/', random_bytes(512))

Best regards,
Ayesh.

On Mar 4, 2026, at 4:22 PM, Tim Düsterhus <tim@bastelstu.be> wrote:

Hi

Am 2026-03-04 20:24, schrieb Calvin Buckley:

What this PR will do is effectively turn this:

Warning: unlink('/tmp'): Operation not permitted in /Users/calvin/src/chmod.php on line 3
Warning: chown('/', 'calvin'): Operation not permitted in /Users/calvin/src/chmod.php on line 4
Warning: chmod('/', 511): Operation not permitted in /Users/calvin/src/chmod.php on line 5

Into this:

Warning: unlink(/tmp): Operation not permitted in /Users/calvin/src/chmod.php on line 3
Warning: chown(): Operation not permitted in /Users/calvin/src/chmod.php on line 4
Warning: chmod(): Operation not permitted in /Users/calvin/src/chmod.php on line 5

Did you mix up the two code blocks? I suspect the first block block is the “New” output and the second one the “Old” output?

Best regards
Tim Düsterhus

An oopsie indeed with a copy-paste error.

Hi

Am 2026-03-04 20:24, schrieb Calvin Buckley:

Because this may not always be desirable (i.e. log size, logging PII
that wasn't tagged as sensitive, not having to rewrite every .phpt
file), this will be an INI option. We can vote on what should be the
defaults, and what should be done with tests. Note that the docref's
parameter will be displayed if it's turned off (or i.e. out of memory).

That makes sense to me.

I think this will almost certainly need an RFC; if there's interest,
I'll start working on that.

I'm interested.

Best regards
Tim Düsterhus

Hi Calvin,

Il 04/03/2026 20:24, Calvin Buckley ha scritto:

I think this will almost certainly need an RFC; if there's interest,
I'll start working on that.

Nice, I can think about lots of occasions where it could have proved to be useful.

As pointed out in the comment:

I think it would be great to have it enabled by default, while keeping it off for regular tests.

Cheers
--
Matteo