stechstudio/laravel-php-cs-fixer

使用此配置文件和伴随的 artisan 命令轻松格式化您的 Laravel 代码。

v3.1.0 2022-02-10 22:40 UTC

README

此包已弃用。我们鼓励您查看Laravel Pint

Laravel PHP CS Fixer

PHP CS Fixer 在 GitHub 上维护,地址为 https://github.com/FriendsOfPHP/PHP-CS-Fixer,欢迎在此处提交错误报告和新功能建议。

PHP编码标准修复工具(PHP CS Fixer)可以将您的代码修复为符合标准;无论是想要遵循 PSR-1、PSR-2 等定义的 PHP 编码标准,还是其他社区驱动的标准,如 Symfony。您还可以通过配置定义自己的(团队)风格。

此包通过提供您已经熟悉的工具来访问 PHP CS Fixer,使得维护您的 Laravel 代码变得更加容易。一个用于修复代码的 artisan 命令,以及管理配置的方式,就像您使用其他所有 Laravel 包一样。

此包的功能

  • 通过 Laravel Artisan CLI 运行 PHP-CS-Fixer 命令。
  • 默认使用 Laravel 代码风格配置。
  • 无需学习新工具。

版本和兼容性

注意:此文档是为 Laravel 5.5 编写的。

  • PHP 版本: "^7.1.3 || ^8.0"
  • Laravel/Lumen: "^5.4|^6.0|^7.0|^8.0"
  • PHP-CS-Fixer: "^3.0.0"

安装

composer require stechstudio/laravel-php-cs-fixer

配置

默认规则配置在 fixer.php 中,旨在匹配 Laravel Shift 使用的规则。

如果您想自己修改,只需使用 artisan 命令 php artisan vendor:publish --provider="STS\Fixer\FixerServiceProvider",它将默认配置放入 'config/fixer.php'。有关有效规则的更多信息,请参阅
PHP-CS-Fixer/README

使用

修复您的代码

使用 Laravel 代码标准修复您的代码。

语法

$ php artisan fixer:fix [options]

示例

Usage:
  fixer:fix [options] [--] [<path>...]

Arguments:
  path                               The path. Can be a list of space separated paths

Options:
      --path-mode=PATH-MODE          Specify path mode (can be override or intersection). [default: "override"]
      --allow-risky=ALLOW-RISKY      Are risky fixers allowed (can be yes or no).
      --config=CONFIG                The path to a .php-cs-fixer.php file.
      --dry-run                      Only shows which files would have been modified.
      --rules=RULES                  The rules.
      --using-cache=USING-CACHE      Does cache should be used (can be yes or no).
      --cache-file=CACHE-FILE        The path to the cache file.
      --diff                         Also produce diff for each file.
      --format=FORMAT                To output results in other formats.
      --stop-on-violation            Stop execution on first violation.
      --show-progress=SHOW-PROGRESS  Type of progress indicator (none, dots).
  -h, --help                         Display help for the given command. When no command is given display help for the list command
  -q, --quiet                        Do not output any message
  -V, --version                      Display this application version
      --ansi                         Force ANSI output
      --no-ansi                      Disable ANSI output
  -n, --no-interaction               Do not ask any interactive question
      --env[=ENV]                    The environment the command should run under
  -v|vv|vvv, --verbose               Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug