chromatix/phpcs-config-chromatix-no-wordpress

类似于 phpcs-config-chromatix,但不包含只能用于 WordPress 上下文中的规则。

v0.0.4 2017-11-23 05:10 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:14:37 UTC


README

phpcs-config-chromatix 类似,但不包含只能用于 WordPress 上下文中的规则。

此配置仍在开发中。 如果您有改进建议或对配置中任何操作有异议,请随时提交问题。如果不是针对此配置的具体问题,请在上游提交(例如在 phpcs-config-chromatix 上)。

安装

全局安装以在任意项目中使用

composer global install chromatix/phpcs-config-chromatix-no-wordpress

局部安装到一个项目中

composer install chromatix/phpcs-config-chromatix-no-wordpress

您还需要以相同的方式安装 phpcs,并按照以下方式设置您的 phpcs installed_paths

vendor/bin/phpcs --config-set installed_paths ../../chromatix,../../wp-coding-standards/wpcs

最好在您的 composer.json 中的 post-install-cmd 脚本中执行此操作;请参阅此包的 composer.json 以获取跨平台方法的示例(它可能看起来有点复杂,但不幸的是这是必需的...至少到目前为止我们的测试是这样的!)。

使用方法

将此添加到您的 phpcs.xml 文件中

<?xml version="1.0"?>
<ruleset>
  <rule ref="phpcs-config-chromatix-no-wordpress"/>
</ruleset>

然后

  • 是否全局使用?

    运行 phpcs *.php

  • 是否局部使用?

    运行 vendor/bin/phpcs *.php

    或者,您可能会发现将脚本添加到您的 composer.json 中很有用

    "scripts": {
      "lint": "find . -type d \\( -name '.git' -o -name 'vendor' -o -name 'node_modules' \\) -prune -o -type f -name '*.php' -print | xargs vendor/bin/phpcs"
    }
    

    然后您只需运行 composer lint

另请参阅

许可证

MIT.