drew / debug-statements-fixers
Removes debug statements, which shouldn't be in production ever
Installs: 427 843
Dependents: 1
Suggesters: 0
Security: 0
Stars: 22
Watchers: 5
Forks: 2
Open Issues: 7
Requires
Requires (Dev)
- gecko-packages/gecko-php-unit: ^2.0
- phpunit/phpunit: ^4.5|^5
- satooshi/php-coveralls: ^1.0
This package is not auto-updated.
Last update: 2024-11-10 02:24:47 UTC
README
Fixers set for PHP-CS-Fixer. Removes debug statements, which shouldn't be in production ever.
If you have ever had 500 Error on production because dump()
function is missing,
or you forget to remove debug statements time to time - this small package is for you.
Debug statements are good for debugging, but it should never get to master branch.
Initially proposed as RFC in PHP-CS-Fixer repository, it was considered too risky to have it in core (see discussion at PHP-CS-Fixer/PHP-CS-Fixer#2218)
N.B. These fixers are risky and potentially can break your application. You should understand consequences of having it in your project (especially a legacy one). You are warned.
Functions being removed:
- dump()
- var_dump()
- dd()
Usage
-
Install it:
$ composer require drew/debug-statements-fixers:^0.4 --dev
-
Adjust your PHP-CS-Fixer config:
# .php_cs.dist <?php $finder = PhpCsFixer\Finder::create() ->in([__DIR__.'/src', __DIR__.'/tests']); return PhpCsFixer\Config::create() ->setRules([ //any fixers you would like to have 'RemoveDebugStatements/dump' => true, ]) ->registerCustomFixers([new Drew\DebugStatementsFixers\Dump()]) ->setRiskyAllowed(true) ->setFinder($finder);
-
Enjoy.
Protip!
Works best when integrated with your CI server, just add this step to your CI config:
$ php vendor/bin/php-cs-fixer fix --diff --dry-run -v