Find forgotten variables dump in PHP source code.

Last update: Mar 12, 2022

PHP VarDump Check

This repository is abandoned.

Suggested alternative: https://github.com/php-parallel-lint/PHP-Var-Dump-Check


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": {
        "jakub-onderka/php-var-dump-check": "~0.3"
    }
}

For colored output install suggested package jakub-onderka/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
  • --extensions php,phpt,php7 - map file extensions for check

Recommended setting for usage with Symfony framework

For run from command line:

$ ./vendor/bin/var-dump-check --symfony --exclude app --exclude vendor .

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>

Build Status Downloads this Month Latest stable

GitHub

https://github.com/jakubonderka/php-var-dump-check
Comments
  • 1. New release?

    Last version of the package is v0.2 which is released on Mar 13, 2015. The README states that there are options such as --symfony, --laravel, --doctrine but in the latest release these options are not available. Do you plan to release a new version with the latest changes in the master branch?

    Reviewed by malios at 2017-05-09 08:21
  • 2. Add the Symfony Vardumper dd() helper method introduced in 4.1

    https://symfony.com/doc/current/components/var_dumper.html#the-dump-function

    The VarDumper component also provides a dd() ("dump and die") helper function. This function dumps the variables using dump() and immediately ends the execution of the script (using exit). New in version 4.1: The dd() helper method was introduced in Symfony 4.1.

    Reviewed by antograssiot at 2018-10-02 07:54
  • 3. Bug in check count dumps

    For test

        ...
        public function __construct()
        {   
            $settings = new PhpVarDumpCheck\Settings();
            $settings->functionsToCheck = array_merge($settings->functionsToCheck, array(
                PhpVarDumpCheck\Settings::DEBUGGER_DUMP,
                PhpVarDumpCheck\Settings::DEBUGGER_DUMP_SHORTCUT,
            )); 
            $this->uut = new PhpVarDumpCheck\Checker($settings);
        } 
    
        public function testCheck_tracyDebugDump()
        {   
            $content = <<<PHP
    <?php
    Debugger::dump(\$var);
    OtherClass::dump(\$var);
    PHP;
            $result = $this->uut->check($content);
            $this->assertCount(1, $result);
        }
        ...
    

    is failure output (from PHPUnit)

    There were 1 failures:
    
    1) TracyTest::testCheck_tracyDebugDump
    Failed asserting that actual size 2 matches expected size 1.
    
    Reviewed by grogy at 2014-11-17 09:12
  • 4. Check Doctrine dump

    Doctrine has its own dump method, which strips a lot of internal information and recursions.

    \Doctrine\Common\Util\Debug::dump($var);
    

    Is there a chance this could be included into this nice tool?

    Reviewed by seaneble at 2016-07-27 13:59
  • 5. Added configuration file for Travis-CI

    Please add this library to Travis-CI.

    I think tests on Travis are elementary for users of library. After I can send next pull-requests:

    • modify readme (Travis)
    • add next tests and support for actual Tracy
    • add new features (search dumps in Latte templates, etc.)
    Reviewed by grogy at 2014-10-29 19:35
  • 6. Expanding Laravel preset

    Hi,

    Very nice tool, good job man. :)

    Laravel also has a dump helper, but it's currently not being detected with the Laravel preset.

    https://laravel.com/docs/5.7/helpers#method-dump

    Also, the Laravel preset doesn't seem to pick up on dd() in Blade files. When used as {{ dd($foo) }}

    Is this something you would be interested in adding to the current preset?

    Reviewed by jasperjorna at 2018-10-17 20:16
  • 7. Feature request: Check symfony VarDumper

    In Symfony 2.6 added VarDumper. http://symfony.com/blog/new-in-symfony-2-6-vardumper-component Dump function can be in Twig or source code. If you forget to remove featuring production environment, it would be a exception.

    Thanks.

    Reviewed by agentsib at 2015-08-22 07:14
  • 8. Add --custom-function parameter to check

    In one of the projects that I have been working for a while, there are some legacy dump functions created and used frequently by the team. A sample function is;

    function pre_dump( $var ) { echo '<pre>'; var_dump( $var ); echo '</pre>'; } The check can not be able to find the usage of such kind of functions. A sample usage might be;

    $ ./vendor/bin/var-dump-check --no-colors --tracy --custom-function pre_dump,echo_dump .

    I have created a pull request for this case.

    https://github.com/JakubOnderka/PHP-Var-Dump-Check/pull/32

    Reviewed by umutphp at 2018-12-13 11:46
  • 9. Add --custom-function parameter to check.

    In one of the projects that I have been working for a while, there are some legacy dump functions created and used frequently by the team. A sample function is;

    function pre_dump( $var ) { echo '<pre>'; var_dump( $var ); echo '</pre>'; }

    The check can not be able to find the usage of this kind of functions. With this pull request, user can give the names of such kind of custom debug functions to the check function with "--custom-function" parameter.

    Reviewed by umutphp at 2018-12-11 12:27
  • 10. Check dump in Latte templates

    Idea: check forgotten dumps from Latte templates. Example of use is in documentation http://doc.nette.org/en/2.2/default-macros#toc-variable-dumping.

    How it implement? That will not do with PHP tokens. Use regular expressions?

    Reviewed by grogy at 2014-12-02 09:27
Preferences are configuration variables that are user-managed for which we cannot rely upon container parameters or environment variables.

Preferences Preferences are configuration variables that are meant to be user managed for which we cannot rely upon container parameters or environmen

Feb 7, 2022
Find undefined and unused variables with the PHP Codesniffer static analysis tool.

PHP_CodeSniffer VariableAnalysis Plugin for PHP_CodeSniffer static analysis tool that adds analysis of problematic variable use. Warns if variables ar

May 24, 2022
The SensioLabs DeprecationDetector runs a static code analysis against your project's source code to find usages of deprecated methods, classes and interfaces

SensioLabs DeprecationDetector CAUTION: This package is abandoned and will no longer receive any updates. The SensioLabs DeprecationDetector runs a st

Feb 21, 2022
Enable ray(), dd() and dump() in all PHP files on your system
Enable ray(), dd() and dump() in all PHP files on your system

Enable ray(), dd() and dump() in all PHP files on your system Ray is a wonderful desktop application that can help you debug applications faster. It c

May 22, 2022
Dump masked information from your database

Laravel Masked DB Dump A database dumping package that allows you to replace and mask columns while dumping your database. Installation You can instal

May 15, 2022
Iran decoration platform is an open source Php web application where you can find your job as a freelancer working in people home in decoration positions and others.

Iran-Decoration Platform Iran decoration platform is an open source Php web application where you can find your job as a freelancer working in people

Feb 12, 2022
This is a library to serialize PHP variables in JSON format

This is a library to serialize PHP variables in JSON format. It is similar of the serialize() function in PHP, but the output is a string JSON encoded. You can also unserialize the JSON generated by this tool and have you PHP content back.

Feb 12, 2022
A simple library to increase the power of your environment variables.
A simple library to increase the power of your environment variables.

Environment A simple library (with all methods covered by php unit tests) to increase the power of your environment variables, contribute with this pr

Feb 8, 2022
This library implements a fuzzer for PHP, which can be used to find bugs in libraries

PHP Fuzzer This library implements a fuzzer for PHP, which can be used to find bugs in libraries (particularly parsing libraries) by feeding them "ran

May 17, 2022
JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

Apr 15, 2022
Simple library that abstracts different metrics collectors. I find this necessary to have a consistent and simple metrics (functional) API that doesn't cause vendor lock-in.

Metrics Simple library that abstracts different metrics collectors. I find this necessary to have a consistent and simple metrics API that doesn't cau

Apr 27, 2022
Hi Im L, I found a box that I believe it's contain Kira's real ID. for open that box we need to find three keys. let's start looking for them
Hi Im L, I found a box that I believe it's contain Kira's real ID. for open that box we need to find three keys. let's start looking for them

DeathNote ctf Description are you smart enaugh to help me capturing the three keys for open the box that contain the real ID of kira? Let's start solv

Apr 19, 2022
VoteSwiper helps citizens to find a political party that matches their own views in a playful way.

VoteSwiper / WahlSwiper - Website VoteSwiper (in Germany better known as WahlSwiper) is a cross-platform voting advice app for Android, iOS and web br

May 12, 2022
IgAnalyzer - Find non-followers and potential stalkers.
IgAnalyzer - Find non-followers and potential stalkers.

igAnalyzer Features Shows mutual followers, non-followers and non-followings via pie chart Shows monthly followers via area chart Shows followers via

Jan 20, 2022
As many Magento patches as I can find!

Magento Resources and Links I have been looking for a good repository for all resources for Magento and I thought I will start putting them here for n

Apr 1, 2022
Magento commands to find translations that are present in one CSV file but not in another, and to translate CSV dicts with DeepL
Magento commands to find translations that are present in one CSV file but not in another, and to translate CSV dicts with DeepL

Hyvä Themes - Magento translation CSV comparison command hyva-themes/magento2-i18n-csv-diff This module adds the bin/magento i18n:diff-csv and i18n:tr

Apr 7, 2022
The main website source code based on php , html/css/js and an independent db system using xml/json.
The main website source code based on php , html/css/js and an independent db system using xml/json.

jsm33t.com Well umm, a neat website LIVE SITE » View Demo · Report Bug · Request a feature About The Project Desc.. Built Using Php UI Frameworks Boot

May 3, 2022
Result of our code-along meetup writing PHP 8.1 code

PHP 8.1 Demo Code This code demonstrates various PHP 8.0 and 8.1 features in a realistic, functional (but incomplete) codebase. The code is part of so

Nov 14, 2021
Dead Code Detector (DCD) for PHP code.

This project is no longer maintained and its repository is only kept for archival purposes. PHP Dead Code Detector (PHPDCD) phpdcd is a Dead Code Dete

May 11, 2022