juliangut / php-cs-fixer-custom-fixers
PHP CS Fixer 自定义修复器
1.1.1
2024-08-22 13:19 UTC
Requires
- php: ^8.0
- friendsofphp/php-cs-fixer: ^3.61.1
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^1.0
- infection/infection: ~0.24|~0.27
- juliangut/phpstan-config: ^1.2
- overtrue/phplint: ^9.0
- phpcompatibility/php-compatibility: ^9.3
- phpmd/phpmd: ^2.14
- phpstan/phpstan: ^1.11
- phpunit/phpunit: ^9.6.13|^10.4
- povils/phpmnd: ^3.3
- roave/security-advisories: dev-master
- slevomat/coding-standard: ^8.0
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-09-23 21:53:21 UTC
README
php-cs-fixer-custom-fixers
为 PHP-CS-Fixer 提供自定义修复器
安装
Composer
composer require --dev juliangut/php-cs-fixer-custom-fixers
使用方法
在 PHP-CS-Fixer 配置中注册自定义修复器
<?php use Jgut\PhpCsFixerCustomFixers\Fixers; use Jgut\PhpCsFixerCustomFixers\Fixer\Comment\LeadingUppercaseCommentFixer; use Jgut\PhpCsFixerCustomFixers\Fixer\Comment\PhpdocLeadingUppercaseSummaryFixer; use Jgut\PhpCsFixerCustomFixers\Fixer\LanguageConstruct\FloatLeadingZeroFixer; use PhpCsFixer\Config; return (new Config()) + ->registerCustomFixers(new Fixers()) ->setRules([ '@PSR2' => true, // ..., + LeadingUppercaseCommentFixer::name() => true, + PhpdocLeadingUppercaseSummaryFixer::name() => true, + FloatLeadingZeroFixer::name() => true, ]);
修复器
语言构造
FloatLeadingZeroFixer
浮点值是否应该或不应该有前导零
<?php class Foo { - private float $value = .5; + private float $value = 0.5; }
配置
leading_zero (字符串), 应该 添加
或应该 移除
前导零
注释
LeadingUppercaseCommentFixer
注释应以首字母大写开头
<?php -// this is a comment +// This is a comment /* - * this is a block comment + * This is a block comment */
PhpdocLeadingUppercaseSummaryFixer
文档块摘要应以首字母大写开头
<?php class Foo { /** - * this is a docblock summary. + * This is a docblock summary. */ public function bar() { } }
贡献
发现了一个错误或有一个功能请求? 请打开一个新问题。在提交之前,请先查看现有的问题。
查看文件 CONTRIBUTING.md
许可证
有关许可证条款的副本,请参阅源代码中包含的文件 LICENSE。