Displaying function arguments in errors

From: Date: Wed, 04 Mar 2026 19:24:11 +0000
Subject: Displaying function arguments in errors
Groups: php.internals 
Request: Send a blank email to internals+get-130249@lists.php.net to get a copy of this message
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: https://github.com/php/php-src/pull/12276

« previous php.internals (#130249) next »