guni / php-var-dump-check
Find forgotten variables dump in PHP source code.
Installs: 156
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/guni/php-var-dump-check
Requires
- php: >=8.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.54
- php-parallel-lint/php-console-highlighter: ^1.0
- phpmd/phpmd: ^2.15
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-strict-rules: ^1.5
- phpstan/phpstan-symfony: ^1.3
- phpunit/phpunit: ^12.2
- rector/rector: ^1.2
- symfony/phpunit-bridge: ^7.3
Suggests
- php-parallel-lint/php-console-highlighter: For colored console output
README
PHP console application for find forgotten variable dump. Support PHP build in method
print_r, var_dump and var_export method and also method from Tracy debugger, Ladybug,
Symfony, Laravel, Doctrine and Zend Framework.
Install
Just create a composer.json file and run the php composer.phar install command to install it:
{
    "require-dev": {
        "guni/php-var-dump-check": "~0.4"
    }
}
For colored output install suggested package php-parallel-lint/php-console-highlighter.
Usage and example output
$ ./vendor/bin/var-dump-check --no-colors --tracy .
...................X...
Checked 23 files in 0.1 second, dump found in 1 file
------------------------------------------------------------
Forgotten dump 'var_dump' found in ./test.php:36
    34|         $functionsToCheck = $this->prepareFunctionCheck($this->settings->functionsToCheck);
    35|
  > 36| 	    var_dump($functionsToCheck);
    37|
    38|         foreach ($tokens as $key => $token) {
Options for run
- none - check dump: var_dump,var_export,print_r
- --ladybug- check dump:- ladybug_dump,- ladybug_dump_die,- ld,- ldd
- --tracy- check dump:- dump,- bdump,- Debugger::dump,- Debugger::barDump
- --zend- check dump:- Zend_Debug::dump,- \Zend\Debug\Debug::dump
- --doctrine- check dump:- Doctrine::dump,- \Doctrine\Common\Util\Debug::dump
- --symfony- check dump:- dump,- VarDumper::dump,- VarDumper::setHandler,- VarDumper::dd
- --laravel- check dump:- dd,- dump
- --no-colors- disable colors from output
- --exclude folder/- exclude folder/ from check
- --incluse folder/- include folder/ to check
Recommended setting for usage with Symfony framework
For run from command line:
$ ./vendor/bin/var-dump-check --symfony --include src
or setting for ANT:
<condition property="var-dump-check" value="${basedir}/bin/var-dump-check.bat" else="${basedir}/bin/var-dump-check">
    <os family="windows"/>
</condition>
<target name="var-dump-check" description="Run PHP VarDump check">
    <exec executable="${var-dump-check}" failonerror="true">
        <arg line='--exclude ${basedir}/app/' />
        <arg line='--exclude ${basedir}/vendor/' />
        <arg line='${basedir}' />
    </exec>
</target>