承接 the-events-calendar/coding-standards 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

the-events-calendar/coding-standards

最新稳定版本:2.1.1

Composer 安装命令:

composer require the-events-calendar/coding-standards

包简介

Code sniffing rules for StellarWP

README 文档

README

StellarWP coding standards uses a combination of:

  • Generic (part of PHP_CodeSniffer)
  • PEAR (part of PHP_CodeSniffer)
  • PSR2 (part of PHP_CodeSniffer)
  • Squiz (part of PHP_CodeSniffer)
  • Zend (part of PHP_CodeSniffer)
  • Custom sniffs (a few based on WordPress)

Important

Make sure that the command phpcs is on version 3.4.2+. In order to install it on that specifc version globally you can use:

composer global require "squizlabs/php_codesniffer=3.4.2"

Complete Installation Script

For a full installation of all required components, you can use the following script. This will install all necessary packages globally and configure PHPCS to use them:

#!/bin/bash

# Install PHP_CodeSniffer
composer global require "squizlabs/php_codesniffer=^3.8.0"

# Install required coding standards and dependencies
composer global require "wp-coding-standards/wpcs:^3.0.0"
composer global require "automattic/vipwpcs:^3.0"
composer global require "phpcsstandards/phpcsextra:*"
composer global require "phpcsstandards/phpcsutils:*"
composer global require "stellarwp/coding-standards:*"
composer global require "sirbrillig/phpcs-variable-analysis:*"
composer global require "slevomat/coding-standard:^8.14.0"

# Update PHPCS installed paths to include all standards
phpcs --config-set installed_paths "$(phpcs --config-show | grep installed_paths | awk '{ print $2 }'),${HOME}/.composer/vendor/phpcsstandards/phpcsextra,${HOME}/.composer/vendor/phpcsstandards/phpcsutils,${HOME}/.composer/vendor/wp-coding-standards/wpcs,${HOME}/.composer/vendor/automattic/vipwpcs,${HOME}/.composer/vendor/stellarwp/coding-standards,${HOME}/.composer/vendor/sirbrillig/phpcs-variable-analysis,${HOME}/.composer/vendor/slevomat/coding-standard"

# Verify installation
echo "Installed PHPCS version:"
phpcs --version
echo ""
echo "Installed coding standards:"
phpcs -i

Note

The script assumes your global Composer binaries are in your PATH. Adjust the paths in the script if your Composer global installation directory is different.

Setup on PHPStorm

You can follow this guide the only step you can replace is the one on Installing via Composer by the one above to install the 3.4.2 version instead.

Example Usage via phpcs.xml File

<?xml version="1.0"?>
<ruleset name="StellarWP Coding Standards">
    <rule ref="WordPress-VIP-Go"/>
    <rule ref="WordPress-Docs">
        <exclude-pattern>*/tests/*</exclude-pattern>
    </rule>
    <rule ref="WordPress">
        <exclude name="WordPress.Files.FileName"/>
        <exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
    </rule>
    <rule ref="StellarWP"/>
    
    <!--exclude the rule for violation of direct DB calls as some have no alternative-->
    <rule ref="WordPress.DB.DirectDatabaseQuery">
        <exclude-pattern>src/Test.php</exclude-pattern>
    </rule>
    
    <exclude-pattern>*/tests/_support/_generated/*</exclude-pattern>
    <exclude-pattern>*/vendor/*</exclude-pattern>
</ruleset>

统计信息

  • 总下载量: 1.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 38
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2022-11-16