ivang11/php-style

PHP-CS-Fixer 的 PHP 风格规则

1.1.1 2020-06-23 23:40 UTC

This package is auto-updated.

Last update: 2024-09-24 09:16:25 UTC


README

这是在我所有项目中应用的标准规则。

安装

您可以使用 composerPackagist 安装。

composer require ivang11/php-style --dev

用法

在您的 .php_cs.dist 配置文件中

<?php

// specify the paths to fix

$finder = PhpCsFixer\Finder::create()
    ->notPath('bootstrap/*')
    ->notPath('storage/*')
    ->notPath('vendor')
    ->in([
        __DIR__ . '/app',
        __DIR__ . '/tests',
        __DIR__ . '/database',
    ])
    ->name('*.php')
    ->notName('*.blade.php')
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);


// then call and return the following style function

return Ivang11\styles($finder);

为命令创建别名

在 composer.json 中设置命令

"scripts": {
    "format": [
        "vendor/bin/php-cs-fixer fix"
    ],
}

执行命令

composer format

在 CI 中执行

./vendor/bin/php-cs-fixer fix --dry-run

资源

许可证

MIT 许可证(MIT)。更多信息请参阅 许可证文件