automattic/jetpack-codesniffer
Composer 安装命令:
composer require --dev automattic/jetpack-codesniffer
包简介
Jetpack Coding Standards. Based on the WordPress Coding Standards, with some additions.
README 文档
README
This is a package implementing phpcs sniffs for the Jetpack Coding Standard.
This standard is generally that of WordPress, with a few additions.
Usage
In your project's composer.json, add the following lines:
{
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "*",
"automattic/jetpack-codesniffer": "^1"
}
}
Your project must use the default composer vendor directory, vendor.
You should then include the Jetpack rules in your .phpcs.xml.dist, like
<rule ref="Jetpack" />
You will also likely want to set some configuration for other included rulesets:
<config name="minimum_supported_wp_version" value="6.9" /> <config name="testVersion" value="7.2-"/>
Included Standards
The Jetpack standard includes the following other standards:
- PHPCompatibilityWP
- WordPress-Core, WordPress-Docs, and WordPress-Extra
- VariableAnalysis
- Selected sniffs from MediaWiki
Included Sniffs
Custom sniffs defined by this standard are documented in the docs subdirectory.
Per-dir Compatibility
This ruleset is intended to be used with PHPCompatibiity's testVersion set to 7.2-.
If used with automattic/jetpack-phpcs-filter's per-directory configuration,
you may run into a situation where a subdir wants to be compatible down to a later version, but as PHPCompatibiity uses <config> for testVersion the setting cannot be directly altered per directory.
To assist with this case, we provide additional rulesets that disable PHPCompatibility rules detecting issues that only apply to older versions:
<rule ref="Jetpack-Compat-73" />will disable rules detecting issues that only apply to PHP < 7.3.<rule ref="Jetpack-Compat-74" />will disable rules detecting issues that only apply to PHP < 7.4.<rule ref="Jetpack-Compat-80" />will disable rules detecting issues that only apply to PHP < 8.0.<rule ref="Jetpack-Compat-81" />will disable rules detecting issues that only apply to PHP < 8.1.<rule ref="Jetpack-Compat-82" />will disable rules detecting issues that only apply to PHP < 8.2.<rule ref="Jetpack-Compat-83" />will disable rules detecting issues that only apply to PHP < 8.3.<rule ref="Jetpack-Compat-84" />will disable rules detecting issues that only apply to PHP < 8.4.<rule ref="Jetpack-Compat-85" />will disable rules detecting issues that only apply to PHP < 8.5.
Note this isn't a perfect replacement for raising testVersion, as it cannot add PHPCompatibility rules that do not trigger when testVersion indicates support for PHP 7.2.
For example, Jetpack-Compat-74 disables the PHPCompatibility.Classes.NewTypedProperties.Found rule ("Typed properties are not supported in PHP 7.3 or earlier") but cannot enable more specific rules like PHPCompatibility.Classes.NewTypedProperties.UnionTypeFound ("Union types are not present in PHP version 7.4 or earlier") that would be triggered if testVersion were set to 7.4-.
You may also run into cases where certain subdirectories contain code that is not intended to run under WordPress. We provide additional rulesets to help with this situation as well:
<rule ref="Jetpack-Compat-NoWP" />will re-enable rules that PHPCompatibilityWP disables because WordPress provides polyfills for various functions.<rule ref="Jetpack-NoWP" />includes Jetpack-Compat-NoWP and disables additional rules checking for use of WordPress-provided functions over PHP-native ones.<rule ref="Jetpack-Tests" />will disable certain rules that do not make much sense in PHPUnit tests.
automattic/jetpack-codesniffer 适用场景与选型建议
automattic/jetpack-codesniffer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 101.76k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「testing」 「standards」 「phpcs」 「codesniffer」 「dev」 「jetpack」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 automattic/jetpack-codesniffer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 automattic/jetpack-codesniffer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 automattic/jetpack-codesniffer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP_CodeSniffer custom Sniff for Laravel coding standard
A set of abstractions that define core services provided by the DVSA
Testing Suite For Lumen like Laravel does.
This is the ZooRoyal coding standard.
Vanio Coding Standard Ruleset for PHP_CodeSniffer.
The coding standard applying to all Youdot PHP projects, based on Doctrine set of PHPCS rules, with additional checks.
统计信息
- 总下载量: 101.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-19