定制 byteever/byteever-sniffs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

byteever/byteever-sniffs

Composer 安装命令:

composer require byteever/byteever-sniffs

包简介

A comprehensive PHP_CodeSniffer ruleset extending WordPress Coding Standards with ByteEver-specific conventions for modern PHP development

README 文档

README

A comprehensive PHP_CodeSniffer ruleset that extends WordPress Coding Standards with ByteEver-specific conventions for modern PHP development.

Features

  • 🎯 WordPress-First: Built on top of WordPress Coding Standards (WPCS) 3.1.0
  • 🐘 PHP Compatibility: Supports PHP 7.4 - 8.5 with PHPCompatibility checks
  • Performance: Configured for parallel processing with 8 threads
  • 🎨 Sensible Defaults: Pre-configured with practical exclusions for real-world development
  • 📝 Tab Indentation: Enforces consistent tab-based indentation
  • 🔧 Customizable: Easy to extend and override rules per project

What's Included

Base Standards

  • WordPress: Complete WordPress coding standards
  • WordPress-Extra: Additional WordPress-specific rules
  • WordPress-Docs: Documentation standards
  • PHPCompatibilityWP: WordPress-specific PHP compatibility checks

ByteEver Customizations

  • Tab-based indentation (1 tab = 1 indent level)
  • Space inside parentheses for better readability
  • Relaxed file naming requirements
  • Allowance for shorthand array syntax []
  • Sensible exclusions for database queries and nonce verification
  • Comment and doc comment tokens ignored in indentation checks

Installation

Install via Composer:

composer require byteever/byteever-sniffs

The package will automatically:

  • Install PHP_CodeSniffer and required dependencies
  • Register the ByteEver-Default standard
  • Set it as the default standard for your project

Usage

Command Line

Quick Check

vendor/bin/phpcs .

Using Composer Script

composer run phpcs

Custom Configuration

vendor/bin/phpcs --standard=ByteEver-Default path/to/files

IDE Integration

For better IDE integration, create a .phpcs.xml.dist file in your project root:

<?xml version="1.0"?>
<ruleset name="Project Coding Standards">
    <description>Project-specific coding standards based on ByteEver defaults.</description>

    <!-- Scan these directories -->
    <file>src/</file>
    <file>inc/</file>
    
    <!-- Exclude these paths -->
    <exclude-pattern>vendor/</exclude-pattern>
    <exclude-pattern>node_modules/</exclude-pattern>
    <exclude-pattern>*.min.js</exclude-pattern>

    <!-- Configuration -->
    <config name="minimum_supported_wp_version" value="6.2" />
    <config name="testVersion" value="7.4-8.5" />

    <!-- Use ByteEver standards -->
    <rule ref="ByteEver-Default" />

    <!-- Project-specific customizations -->
    <rule ref="WordPress.WP.I18n">
        <properties>
            <property name="text_domain" type="array">
                <element value="your-text-domain"/>
            </property>
        </properties>
    </rule>
</ruleset>

Continuous Integration

Add to your CI workflow:

# GitHub Actions example
- name: PHP CodeSniffer
  run: composer run phpcs

Configuration Details

PHP Version Support

  • Minimum: PHP 7.4
  • Maximum: PHP 8.5
  • Compatibility: Uses PHPCompatibilityWP for WordPress-specific compatibility checks

Key Rules Applied

  • WordPress Coding Standards (with sensible exclusions)
  • Tab indentation (1 tab per indent level)
  • Space inside parentheses for readability
  • Superfluous whitespace detection
  • PHP compatibility checking for WordPress

Excluded Rules

The following rules are excluded for practical development:

  • File naming conventions (WordPress.Files.FileName)
  • Nonce verification requirements
  • Direct database query restrictions
  • Global variable override prohibitions
  • Some documentation capitalization requirements

Customization

Project-Level Overrides

Create a phpcs.xml.dist file to override or add rules:

<rule ref="ByteEver-Default">
    <!-- Enable a rule that's disabled by default -->
    <exclude name="WordPress.Files.FileName" />
</rule>

<!-- Add custom exclusions -->
<rule ref="WordPress.Security.NonceVerification.Missing">
    <exclude-pattern>admin/ajax-handlers/*</exclude-pattern>
</rule>

Inline Annotations

Disable rules for specific code blocks:

// phpcs:disable WordPress.Security.NonceVerification.Missing
if ( isset( $_POST['data'] ) ) {
    // Process data without nonce check
}
// phpcs:enable WordPress.Security.NonceVerification.Missing

Requirements

  • PHP 7.4 or higher
  • Composer
  • PHP_CodeSniffer 3.9.0 or higher

Dependencies

  • dealerdirect/phpcodesniffer-composer-installer: ^1.0
  • phpcompatibility/phpcompatibility-wp: ^2.1
  • wp-coding-standards/wpcs: ^3.1.0

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test with composer run phpcs
  5. Submit a pull request

License

GPL-3.0-only

Author

Sultan Nasir Uddin
Email: sultan@byteever.com
Organization: ByteEver

Part of the ByteEver development toolkit for WordPress and PHP projects.

byteever/byteever-sniffs 适用场景与选型建议

byteever/byteever-sniffs 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 7.06k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 10 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: Shell

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2023-10-25