GithubHelp home page GithubHelp logo

dump-linter's Introduction

Total Downloads Issues Open Total Downloads Latest Version License


Sometimes you are debugging and end up deploying with your code a dumpor a var_dump (if you're a Laravel dev, the infamous dd) and that could be annoying, so Dump Linter is a package that complements PHP-CS-Fixer, providing a rule to remove dump statements from the source code.

โ— IMPORTANT: the rule is considered risky by PHP-CS-Fixer metrics because technically dump/var_dump are not errors or bad writing, so be careful and use this rule if you're completely sure that you don't want them in the codebase.

REQUIREMENTS

PHP 8.1+

PHP-CS-Fixer 3

HOW TO INSTALL

To install the package, just use composer:

composer require tombenevides/dump-linter

HOW TO USE

Configuring PHP-CS-Fixer

After installing, you need to edit the .php-cs-fixer.dist.php file (or the file that you're chose), adding the custom rule using registerCustomFixers() function and then set the rule, as you can see below:

$config = new PhpCsFixer\Config();

return $config
    ->registerCustomFixers([
        new \Tombenevides\DumpLinter\DumpRemovalFixer()
    ])
    ->setRules([
        '@PSR12' => true,
        'Tombenevides/dump_removal' => true,
        ...
    ])

List of dump statements that will be removed: dump(),var_dump(),dd(),ray() and dumps().

More info or questions about PHP-CS-Fixer configuration file, just check this link.

Running the linter with custom rule

Since this is a risky rule, the default command php-cs-fixer fix -v will not work. Therefore, to allow the rule to make the expected changes, you need to give the linter permission to perform risky actions. You do this by adding the --allow-risky=yes flag.

LICENSE

Dump Linter is a software under the MIT License

UPDATES

๐Ÿ‘‹ Follow the author @devatreides on Twitter to know more about the last updates and other projects. Say Hi!

dump-linter's People

Contributors

devatreides avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.