pantheon-systems/pantheon-wp-coding-standards

Pantheon 上 WordPress 项目的 PHPCS 规则集。

安装次数: 29,623

依赖: 12

建议: 0

安全: 0

星标: 3

关注者: 7

分支: 1

开放问题: 1

类型:phpcodesniffer-standard

2.0.3 2024-07-05 21:39 UTC

This package is auto-updated.

Last update: 2024-09-23 20:46:04 UTC


README

Actively Maintained Packagist Version MIT License

Pantheon 上 WordPress 项目的 PHPCS 规则集。

安装

PHPCS 规则集可以通过 Composer 安装

composer require --dev pantheon-systems/pantheon-wp-coding-standards

使用

运行以下命令以运行标准检查

vendor/bin/phpcs -s --standard=Pantheon-WP .

我们建议使用 -s 标志,这样 PHPCS 将会报告违反的具体规则。这有助于添加排除项或研究可能的解决方案。

如果您想排除测试目录以避免检查,可以通过添加 --ignore 标志来实现

vendor/bin/phpcs -s --ignore=tests/* --standard=Pantheon-WP .

扩展

如果您想自定义默认设置或添加额外的规则,您可以创建自己的标准文件(例如 phpcs.ruleset.xml

<?xml version="1.0"?>
<ruleset>
	<!-- Files or directories to check -->
	<file>.</file>

	<!-- Include the Pantheon-WP ruleset -->
	<rule ref="Pantheon-WP" />

	<!-- Add additional rules here -->
	<rule ref="WordPress.WP.I18n">
		<properties>
			<property name="text_domain" value="my-plugin" />
		</properties>
</ruleset>

然后您可以在运行 PHPCS 时引用此文件

vendor/bin/phpcs -s --standard=phpcs.ruleset.xml .

包含的检查

Pantheon WP 标准基于 WordPress 编码标准VIP 编码标准,并基于 Human Made 的编码标准 进行了一些自定义。