No Debug Code
July 16, 2015 ยท View on GitHub
Debug code is be of several flavor :
var_dumpandprint_rdebug_print_backtraceanddebug_backtrace(the latter one has to be printed)$php_errormsgvariable (also when printed)ini_setwithdisplay_errorsandhtml_errorsdirectivesprintorechowith information (i.e.echo 'DEBUG';. That includes HTML comments or$debugmessages.- Helper functions or classes, such as Kint, php-ref, dump_r, Krumo, dBug.
<?php
if (!is_object($dbconnexion)) {
debug($dbconnexion);
die();
}
?>
The most suited tool for debugging is a PHP debugger, that will run the code and give a full view of the situation, call stack and variable values. PHP debuggers also allow step by step execution. They are usually integrated with the IDE.
It is recommended to remove all mention to those tools in production code, so as to avoid situations where they are really used (and are in production).
Rule Details
The following patterns are considered warnings:
<?php
print 'debug';
require '/kint/Kint.class.php';
Kint::dump( $_SERVER );
?>