tbibard/debug-statements-fixers 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tbibard/debug-statements-fixers

最新稳定版本:v0.1.0

Composer 安装命令:

composer require tbibard/debug-statements-fixers

包简介

Removes debug statements, which shouldn't be in production ever

README 文档

README

Fixers set for PHP-CS-Fixer. Removes debug statements, which shouldn't be in production ever.

PHP 7.0 Build Status Latest Stable Version Total Downloads License

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

  1. Install it:

    $ composer require drew/debug-statements-fixers:^0.4 --dev
  2. 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);    
  3. 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

统计信息

  • 总下载量: 1.98k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-28