eliashaeussler/php-cs-fixer-config

PHP-CS-Fixer的个人配置

2.2.0 2024-05-17 19:59 UTC

This package is auto-updated.

Last update: 2024-09-22 04:34:35 UTC


README

PHP-CS-Fixer 配置

Coverage Maintainability CGL Tests Supported PHP Versions

本包包含基本PHP-CS-Fixer配置,用于我的个人项目。它不应用于其他地方。我不会为此仓库提供支持,也不接受pull请求。

🔥 安装

Packagist Packagist Downloads

composer require eliashaeussler/php-cs-fixer-config

⚡ 使用

在您的.php-cs-fixer.php文件中配置PHP-CS-Fixer

use EliasHaeussler\PhpCsFixerConfig;
use Symfony\Component\Finder;

// Create header rule
$header = PhpCsFixerConfig\Rules\Header::create(
    'eliashaeussler/package-name',
    PhpCsFixerConfig\Package\Type::ComposerPackage,
    PhpCsFixerConfig\Package\Author::create('Elias Häußler', '[email protected]'),
    PhpCsFixerConfig\Package\CopyrightRange::from(2021),
    PhpCsFixerConfig\Package\License::GPL3OrLater,
);

// Create custom rule set
$ruleSet = PhpCsFixerConfig\Rules\RuleSet::fromArray([
    'modernize_types_casting' => true,
    'php_unit_test_case_static_method_calls' => [
        'call_type' => 'self',
    ],
]);

return PhpCsFixerConfig\Config::create()
    ->withRule($header)
    ->withRule($ruleSet)
    // You can also overwrite all rules
    ->withRule($ruleSet, false)
    ->withFinder(static fn (Finder\Finder $finder) => $finder->in(__DIR__))
    // You can also inject your own Finder instance
    ->withFinder($finder)
;

⭐ 许可证

本项目遵循GNU通用公共许可证3.0(或更新版本)