vena/php-cs-fixer-wordpress
Composer 安装命令:
composer require vena/php-cs-fixer-wordpress
包简介
A custom ruleset for PHP CS Fixer (close to) Wordpress Coding Standards
README 文档
README
This package contains a Frankenstein's monster of rules and fixers for PHP CS Fixer which attempt to satisfy most of the WordPress Coding Standards. It builds upon the @PSR2 and @PhpCsFixer rulesets, along with custom fixers for some WordPress peculiarities.
WPCS rules not covered by this package include, but are not limited to:
- Filename conventions
- Tabs vs Spaces
- Nearly all errors and warnings which are not automatically fixable
Yoda style looks to no longer be required in WPCS 3.0, so it is not required in this ruleset.
I use PHP CS Fixer because I find it easier to integrate into my workflow than PHP_CodeSniffer. If you are not me, and especially if you require WPCS compliance, I highly suggest that you stick with PHP_CodeSniffer and the official WPCS sniffs.
Use
// In case of not using autoload... require __DIR__ . '/includes.php'; $config = new PhpCsFixer\Config(); $RuleSet = new vena\WordPress\PhpCsFixer\WordPressRuleSet(); return $config ->registerCustomFixers( $RuleSet->getCustomFixers() ) // OPTIONAL. See below. ->registerCustomFixers( array( new vena\WordPress\PhpCsFixer\Fixer\WordPressCapitalPDangitFixer(), ) ) ->setRiskyAllowed( $RuleSet->isRisky() ) ->setIndent( "\t" ) ->setRules( array_merge( $RuleSet->getRules(), array( // OPTIONAL. See below. 'Vena/wp_capital_p_dangit' => true, ) ) ) ->setFinder( PhpCsFixer\Finder::create() ->exclude( 'vendor' ) ->in( __DIR__ ) ) ;
Custom Fixers
WordPressParenthesesSpacesFixer
With few exceptions, WPCS specifies spaces after opening and before closing parenthesis.
WordPressArrayIndexSpacesFixer
If a variable is used as an array key, it must be flanked by spaces. All other keys should not have spaces.
WordPressMultilineAssocArrayFixer
For any array which contains multiple items and any associative key, each item must appear on a new line. NOTE: This fixer DOES NOT fix indentation, and should be used with the array_indentation rule.
WordPressCapitalPDangitFixer
Attempts to automatically correct common misspellings of WordPress in strings and comments. Its rule, Vena/wp_capital_p_dangit, is not included in the RuleSet::getRules() helper, and must be added to your config if you intend to use it. Unlike the official WPCS sniff, this does not care about class names. NOTE: This is a risky fixer that may not accurately distinguish safe transforms.
Credits
Test scaffolding is built on the work of Kuba Werłos' PHP CS Fixer: custom fixers
vena/php-cs-fixer-wordpress 适用场景与选型建议
vena/php-cs-fixer-wordpress 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.67k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vena/php-cs-fixer-wordpress 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vena/php-cs-fixer-wordpress 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.67k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-12