tombenevides/dump-linter 问题修复 & 功能扩展

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

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

tombenevides/dump-linter

Composer 安装命令:

composer require tombenevides/dump-linter

包简介

A custom rules to remove dump functions from PHP code

README 文档

README

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!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固