yeremi/cli-standards 问题修复 & 功能扩展

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

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

yeremi/cli-standards

Composer 安装命令:

composer require yeremi/cli-standards

包简介

PHPCS standards for CLI command design, currently focused on WP-CLI code, with blocking and advisory sniffs for safety, automation, output, and documentation.

README 文档

README

PHPCS sniffs for CLI command design quality, currently focused on WP-CLI command code.

This package publishes the CLIStandards coding standard as a Packagist-ready Composer package. It enforces 18 checks derived from the CLI Standards model:

  • 8 blocking checks reported as errors
  • 10 advisory checks reported as warnings

Installation

composer require --dev yeremi/cli-standards

The Composer installer plugin registers the standards automatically. After installation:

vendor/bin/phpcs -i

You should see CLIStandards and CLIStandardsMust in the installed standards list.

Usage

Run the standard against your CLI command code:

vendor/bin/phpcs --standard=CLIStandards path/to/cli/

Useful variants:

# Show sniff codes.
vendor/bin/phpcs --standard=CLIStandards -s path/to/cli/

# Enforce only MUST-level checks.
vendor/bin/phpcs --standard=CLIStandards --warning-severity=0 path/to/cli/

# Emit JSON for CI tooling.
vendor/bin/phpcs --standard=CLIStandards --report=json path/to/cli/

# Run only blocking rules.
vendor/bin/phpcs --standard=CLIStandardsMust path/to/cli/

CLIStandardsMust is intended to behave like CLIStandards with warnings suppressed, which makes it useful for staged CI adoption.

Example Output

Anonymized example from a real local scan:

FILE: sample-plugin/includes/cli/class-command.php
----------------------------------------------------------------------
FOUND 4 ERRORS AND 3 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------
  9 | ERROR   | Command name "sample-command" must include a namespace
    |         | (CLIStandards.CommandStructure.CommandRegistration.MissingNamespace)
 24 | ERROR   | Command docblock must contain a "## OPTIONS" section
    |         | (CLIStandards.Documentation.DocblockOptions.MissingOptionsSection)
 25 | ERROR   | Command docblock must contain a "## EXAMPLES" section
    |         | (CLIStandards.Documentation.DocblockExamples.MissingExamplesSection)
 48 | WARNING | Consider using WP_CLI\Utils\get_flag_value()
    |         | (CLIStandards.Arguments.FlagExtraction.DirectAccess)
 77 | WARNING | Bulk loop should use make_progress_bar()
    |         | (CLIStandards.Scalability.ProgressBar.MissingProgressBar)
----------------------------------------------------------------------

What It Enforces

Error-level sniffs:

  • CommandRegistration
  • FlagNaming
  • OutputMethod
  • ErrorSeverity
  • ConfirmOnDelete
  • ConfirmPassthrough
  • DocblockOptions
  • DocblockExamples

Warning-level sniffs:

  • FlagExtraction
  • StdoutStderr
  • FormatSupport
  • AvailableFields
  • WpErrorHandling
  • DryRunSupport
  • BatchProcessing
  • ProgressBar
  • BatchSizeFlag
  • SinceAnnotation

The implementation is intentionally heuristic in some areas. It favors practical signal over deep semantic analysis, so some checks can still produce false negatives or advisory-only warnings.

Scope

The standard name is generic, but the current implementation is not framework-agnostic. The sniffs are tuned for codebases that expose commands through WP_CLI, and most checks activate only when WP_CLI usage is detected.

Add To phpcs.xml.dist

<?xml version="1.0"?>
<ruleset name="MyPluginStandard">
    <description>Project coding standards.</description>

    <rule ref="CLIStandards"/>

    <file>./includes/cli/</file>
    <exclude-pattern>*/vendor/*</exclude-pattern>
</ruleset>

Development

Install dependencies:

composer install

Run the fixture-based regression suite:

composer test

For contribution workflow and expectations, see CONTRIBUTING.md.

Repository Layout

  • CLIStandards/: the main standard and sniff classes
  • CLIStandardsMust/: blocking-only variant for staged adoption
  • tests/Fixtures/: regression fixtures for expected violations and clean cases
  • scripts/verify-fixtures.php: assertion-based test runner used by CI

License

See LICENSE (MIT).

yeremi/cli-standards 适用场景与选型建议

yeremi/cli-standards 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cli」 「wordpress」 「phpcs」 「wp-cli」 「static-analysis」 「PHPCodeSniffer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yeremi/cli-standards 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yeremi/cli-standards 我们能提供哪些服务?
定制开发 / 二次开发

基于 yeremi/cli-standards 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-01