moderntribe/coding-standards

现代部落PHPCS编码标准

安装数: 24,450

依赖: 7

推荐者: 0

安全: 0

星标: 8

关注者: 3

分支: 2

开放问题: 1

类型:phpcodesniffer-standard

v3.3.0 2023-10-13 14:59 UTC

README

现代部落编码标准是一套主要用于与SquareOne框架一起使用的PHP_CodeSniffer规则。

要求

  • PHP ^8.0

安装

Composer v2

composer require --dev moderntribe/coding-standards "^3.0"`

Composer v1

添加到repositories对象

    {
      "type": "vcs",
      "url": "git@github.com:moderntribe/coding-standards.git"
    }

以及require-dev

  "moderntribe/coding-standards": "^3.0"

项目规则集

确保您在本地上运行PHP 8.0!

要使用此规则集,请在项目的根目录下创建一个phpcs.xml.dist文件并添加以下内容

<?xml version="1.0"?>
<ruleset>
	<arg name="basepath" value="." />
	<arg name="extensions" value="php" />
	<arg name="severity" value="4" />
	<arg name="tab-width" value="4" />
	<arg name="parallel" value="80" />
	<arg name="colors" />

	<!--  Update to the PHP version your production/local docker container runs on -->
	<config name="testVersion" value="8.0" />
	<!-- php -r 'echo PHP_VERSION_ID;' -->
	<config name="php_version" value="80022" />

	<!-- Fix WordPress's terrible typing breaking PHPCS -->
	<config name="minimum_supported_wp_version" value="5.6.0" />

	<!-- Ignore warnings, show progress of the run and show sniff names -->
	<arg value="nps" />

	<!-- Directories to be checked -->
	<file>./wp-content/plugins/core</file>
	<file>./wp-content/themes/core</file>
	<file>./wp-content/mu-plugins</file>

	<!-- Exclude files -->
	<exclude-pattern>*-config.php</exclude-pattern>
	<exclude-pattern>*vendor/</exclude-pattern>
	<exclude-pattern>*tests/*</exclude-pattern>
	<exclude-pattern>*.twig</exclude-pattern>
	<exclude-pattern>*webpack/</exclude-pattern>

	<!-- Include the Modern Tribe coding standard -->
	<rule ref="ModernTribe" />
</ruleset>

phpcs.xml添加到您的.gitignore

手动使用

PHPCS

./vendor/bin/phpcs --standard=ModernTribe /path/to/files/**.php

PHPCBF

./vendor/bin/phpcbf --standard=ModernTribe /path/to/files/**.php

资源