Code Monkey home page Code Monkey logo

php-var-dump-check's Introduction

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

php-var-dump-check's People

Contributors

agentsib avatar antograssiot avatar douglasdc3 avatar grogy avatar jakubonderka avatar wenihal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

php-var-dump-check's Issues

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?

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?

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.

#32

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?

PHP 5.3 support

Hi,

why are tests execute with version 5.3.3? In composer.json is required PHP 5.3.2.

Create a phar release

It would be nice to have a PHAR file available without having to add php-var-dump-check as requirement to projects.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.