定制 jbzoo/codestyle 二次开发

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

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

jbzoo/codestyle

Composer 安装命令:

composer require jbzoo/codestyle

包简介

Collection of QA tools and JBZoo code standards

README 文档

README

CI Coverage Status Psalm Coverage Psalm Level CodeFactor

Stable Version Total Downloads Dependents GitHub License

Comprehensive collection of QA tools and code quality standards for PHP 8.2+ projects. Provides configurations and wrappers for PHPStan, Psalm, PHP-CS-Fixer, PHPUnit, PHPMD, Phan and other popular code analysis tools.

Requirements

  • PHP 8.2+ - Modern PHP version with strict typing support
  • Composer - For dependency management
  • Make - Build automation tool

Installation

composer require --dev jbzoo/codestyle

Quick Start

Add the following to your project's Makefile to get access to all QA tools:

ifneq (, $(wildcard ./vendor/jbzoo/codestyle/src/init.Makefile))
    include ./vendor/jbzoo/codestyle/src/init.Makefile
endif

update: ##@Project Install/Update all 3rd party dependencies
    $(call title,"Install/Update all 3rd party dependencies")
    @echo "Composer flags: $(JBZOO_COMPOSER_UPDATE_FLAGS)"
    @composer update $(JBZOO_COMPOSER_UPDATE_FLAGS)

test-all: ##@Project Run all project tests at once
    @make test
    @make codestyle

Available Tools

This package includes configurations for:

  • PHPStan - Static analysis tool with strict rules
  • Psalm - Advanced static analysis with type coverage
  • PHP-CS-Fixer - Code style fixer with PSR-12 and custom rules
  • PHPCS - Code sniffer for PSR-12 and PHP compatibility
  • PHPMD - Mess detector for code quality issues
  • PHPUnit - Unit testing framework with coverage reporting
  • Phan - Super strict static analyzer
  • PHPMND - Magic number detector
  • PHPCPD - Copy-paste detector

Common Commands

Development

make update          # Install/update dependencies
make autoload        # Dump optimized autoloader
make clean           # Cleanup build directory

Testing

make test           # Run PHPUnit tests
make test-all       # Run all tests and code style checks
make codestyle      # Run all code style linters

Individual QA Tools

make test-phpstan        # Static analysis with PHPStan
make test-psalm          # Static analysis with Psalm
make test-phpcs          # Code sniffer (PSR-12 + compatibility)
make test-phpcsfixer     # Check PHP-CS-Fixer rules
make test-phpcsfixer-fix # Auto-fix with PHP-CS-Fixer
make test-phpmd          # Mess detector
make test-phan          # Phan static analyzer

Reports

make report-all         # Generate all reports
make report-phpmetrics  # PHP Metrics report
make report-pdepend     # PHP Depend report

Complete Command Reference

Usage:
  - `make [target]`
  - `make [target] OPTION=value`
  - `ENV_VAR=value make [target]`

Misc:
  help                          Show this text
  list                          Full list of targets

Project:
  autoload                      Dump optimized autoload file for PHP
  build-phar                    Compile phar file
  clean                         Cleanup only build directory
  clean-vendor                  Cleanup all
  test-all                      Run all project tests at once
  update                        Install/Update all 3rd party dependencies

Tests:
  codestyle                     Launch all codestyle linters at once
  test                          Launch PHPUnit Tests (alias "test-phpunit")
  test-composer                 Validates composer.json and composer.lock
  test-composer-reqs            Checks composer.json the defined dependencies against your code
  test-performance              Run benchmarks and performance tests
  test-phan                     Phan - super strict static analyzer for PHP
  test-phpcpd                   PHPcpd - Find obvious Copy&Paste
  test-phpcs                    PHPcs - Checking PHP Code Sniffer (PSR-12 + PHP Compatibility)
  test-phpcsfixer               PhpCsFixer - Check code to follow stylish standards
  test-phpcsfixer-fix           PhpCsFixer - Auto fix code to follow stylish standards
  test-phpmd                    PHPmd - Mess Detector Checker
  test-phpmd-strict             PHPmd - Mess Detector Checker (strict mode)
  test-phpmnd                   PHPmnd - Magic Number Detector
  test-phpstan                  PHPStan - Static Analysis Tool
  test-phpunit                  PHPUnit - Launch General Tests
  test-psalm                    Psalm - static analysis tool for PHP

Reports:
  report-all                    Build all reports at once
  report-composer-diff          What has changed after a composer update
  report-composer-graph         Build composer graph of dependencies
  report-coveralls              Send coverage report to coveralls.io
  report-merge-coverage         Merge all coverage reports in one clover file
  report-pdepend                Build PHP Depend Report
  report-performance            Build performance summary report
  report-phploc                 PHPloc - Show code stats
  report-phpmetrics             Build PHP Metrics Report
  update-extend                 Checks new compatible versions of 3rd party libraries

Trick: Add into your "~/.bash_aliases" the line "complete -W "\`make list\`" make" to use TAB

Integration with IDEs

The package provides configurations that work seamlessly with:

  • PhpStorm - Built-in support for all tools
  • VS Code - Extensions available for all included tools
  • Vim/Neovim - LSP support through various plugins

Advanced Usage

Custom PHP-CS-Fixer Rules

Extend the base configuration in your .php-cs-fixer.php:

use JBZoo\Codestyle\PhpCsFixer\PhpCsFixerCodingStandard;

return (new PhpCsFixerCodingStandard(__DIR__))
    ->addCustomRules([
        'your_custom_rule' => true,
    ])
    ->getFixerConfig();

PHPUnit Base Classes

Use the provided base test classes for consistent testing:

use JBZoo\Codestyle\PHPUnit\AbstractPackageTest;

class YourPackageTest extends AbstractPackageTest
{
    protected string $packageName = 'your-package-name';
}

Contributing

Contributions are welcome! Please ensure:

  1. All tests pass: make test-all
  2. Code follows our standards: make codestyle
  3. Coverage remains high: make report-all

License

MIT License. See LICENSE file for details.

jbzoo/codestyle 适用场景与选型建议

jbzoo/codestyle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.11M 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 jbzoo/codestyle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-17