oyova/php-cs-fixer

PHP CS Fixer 的包装器。

v1.4.0 2023-09-30 22:36 UTC

This package is auto-updated.

Last update: 2024-09-30 01:18:22 UTC


README

此包是 PHP CS Fixer 的包装器。PHP CS Fixer 用于自动修复 PHP 代码风格问题,此包确立了 Oyova 优先规则并简化了设置。

安装

通过 Composer 安装此包

composer require --dev oyova/php-cs-fixer

设置

在项目根目录中,创建一个名为 .php-cs-fixer.php 的文件,包含以下代码

<?php

return (new Oyova\PhpCsFixer\Setup(__FILE__))
    // ->in(string|array)
    // ->exclude(string|array)
    // ->notName(string|array)
    ->getConfig();

对于 WordPress,使用 Oyova\PhpCsFixer\WordPressSetup 而不是 Oyova\PhpCsFixer\Setup

使用方法

从项目根目录运行命令 vendor/bin/php-cs-fixer fix 修复所有配置的文件,或运行 vendor/bin/php-cs-fixer fix path/to/file.php 修复特定文件或目录。 创建一个 bash 别名 以方便使用(例如 alias phpfix='vendor/bin/php-cs-fixer fix')。