ForgottenDebugOutput
error on by defaultGroup: Probable bugs · PhpStorm name: ForgottenDebugOutputInspection
Dumping, tracing and profiler helpers (var_dump(), print_r(), framework dumpers, Xdebug functions, …) are typically added while debugging and forgotten afterwards. Flag their calls unless the context shows the output is intentional.
Example
Effective list = defaults + audit_dump + \Acme\Tracer::dump + \Acme\Probe::dump (migratedIntoUserSpace = false).
php
<?php
namespace Acme;
use function var_dump;
class Tracer { public static function dump($v) {} }
class Probe { public function dump($v) {} }
class Quiet { public function dump($v) {} }
function audit_dump($v) {
print_r($v);
}
function work($order, Probe $probe, Quiet $quiet) {
var_dump($order, $probe);
\print_r($order);
$text = print_r($order, true);
echo var_export($order, true);
var_export($order);
error_log('order seen', 3, '/var/log/app.log');
debug_print_backtrace();
phpinfo(INFO_GENERAL);
audit_dump($order);
Tracer::dump($order);
$probe->dump($order);
$quiet->dump($order);
ob_start();
var_dump($order);
ob_start();
@print_r($order);
ob_start();
$copy = $order;
var_dump($copy);
}Reported:
- line 15: Debug output call; remove it if it was left over from debugging.
- line 16: Debug output call; remove it if it was left over from debugging.
- line 19: Debug output call; remove it if it was left over from debugging.
- line 20: Debug output call; remove it if it was left over from debugging.
- line 21: Debug output call; remove it if it was left over from debugging.
- line 23: Debug output call; remove it if it was left over from debugging.
- line 24: Debug output call; remove it if it was left over from debugging.
- line 25: Debug output call; remove it if it was left over from debugging.
- line 34: Debug output call; remove it if it was left over from debugging.
Options
| Option | Type | Default | Effect |
|---|---|---|---|
| configuration | list of strings | empty (see below) | Additional debug entries (function_name or \Class::method). |
| migratedIntoUserSpace | bool | false | When false, the built-in defaults are merged into configuration; when true, only configuration is used. |
Upstream persists the merged list into configuration once and flips migratedIntoUserSpace to true; custos only needs the "effective list" semantics above.
Configure
In custos.json:
json
{
"rules": {
"ForgottenDebugOutput": {
"enabled": false,
"options": {
"configuration": [],
"migratedIntoUserSpace": false
}
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore ForgottenDebugOutput
/**
* @noinspection ForgottenDebugOutputInspection
*/