stellarwp/nexcess-coding-standards 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

stellarwp/nexcess-coding-standards

最新稳定版本:v1.0.0

Composer 安装命令:

composer require stellarwp/nexcess-coding-standards

包简介

Centralized coding standards for StellarWP packages

README 文档

README

This package contains a base set of coding standards for StellarWP package development.

The rules are generally based on the PSR-12 coding standard, which is generally recommended within the larger PHP community.

Additionally, since StellarWP is largely-focused on WordPress, our standards also include important WordPress-oriented rules (e.g. late-escaping of output, input sanitization, nonce usage, etc.).

What's included?

There are two main tools included in this package:

PHP_CodeSniffer

PHP_CodeSniffer is the de-facto linting tool for PHP, and there are a number of pre-configured standards available.

This package includes PHP_CodeSniffer itself, along with the WordPress Coding Standards ruleset, PHP compatibility checks, and Dealerdirect's Composer installer for PHP_CodeSniffer.

PHP-CS-Fixer

PHP-CS-Fixer is an additional coding standards checker for PHP, maintained by several members of the Symfony team. It provides a bit more flexibility around more sophisticated checks and experiemental features.

Installation

This package should be installed as a development dependency for your project:

$ composer require --dev stellarwp/coding-standards

This will automatically expose the phpcs, phpcbf, and php-cs-fixer binaries in your project's vendor/bin directory.

You may also wish to add the following Composer scripts to make it easier to run checks:

# composer.json
{
    // ...
    "scripts": {
        // ...
        "test:standards": [
            "phpcs --standard=StellarWP --cache ./src ./tests",
            "php-cs-fixer fix --config=vendor/stellarwp/coding-standards/src/php-cs-fixer.php -v --diff --dry-run"
        ],
        "test:standards-fix": [
            "phpcbf --standard=StellarWP ./src ./tests",
            "php-cs-fixer fix --config=vendor/stellarwp/coding-standards/src/php-cs-fixer.php -v --diff"
        ]
    },
    "scripts-descriptions": [
        "test:standards": "Check coding standards.",
        "test:standards-fix": "Attempt to fix coding standards violations automatically.",
    ]
}

Note: You may need to adjust paths to suit your project, especially if your Composer "vendor-dir" has been changed.

Project-specific configuration

The default coding standards make a few assumptions about the project (all of which may be overwritten on a per-project basis):

Rather than overwriting these values via command-line arguments, it's recommended to create a PHP_CodeSniffer configuration file in your project. An annotated starter configuration is included in this package, and can automatically be copied into the project root (.phpcs.xml.dist) by running the following command:

$ vendor/bin/make-phpcs-config

Should you need to change the rules for PHP-CS-Fixer, you may publish a .php-cs-fixer.dist.php file by running the following:

$ vendor/bin/make-php-cs-fixer-config

If you've copied the default test:standards and test:standards-fix scripts into your composer.json file, please be sure to update their arguments!

# composer.json
{
    // ...
    "scripts": {
        // ...
        "test:standards": [
            "phpcs --cache",
            "php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --diff --dry-run"
        ],
        "test:standards-fix": [
            "phpcbf",
            "php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --diff"
        ]
    },
}

License

This library is licensed under the terms of the MIT license.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 9
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-19