承接 iwf-web/php-coding-standard 相关项目开发

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

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

iwf-web/php-coding-standard

Composer 安装命令:

composer require iwf-web/php-coding-standard

包简介

Configs & RuleSets for PHP Code

README 文档

README

Custom PHP-CS-Fixer rule sets for consistent code style across IWF Web projects.

License Version Version (including pre-releases) Downloads on Packagist

Rule Sets

This package provides two rule sets:

Rule Set Description
@IWFWeb/standard Non-risky coding style rules for consistent formatting
@IWFWeb/standard:risky Risky rules that may change code behavior (use with caution)

Both rule sets build upon the excellent @PhpCsFixer rule set (which includes @Symfony and @PSR12) with customizations tailored for IWF Web projects.

Getting Started

Prerequisites

  • PHP 8.2 or higher
  • PHP-CS-Fixer ^3.88 — the Config::registerCustomRuleSets() method used below was added in 3.88; earlier versions cannot load these rule sets

Installation

composer require --dev iwf-web/php-coding-standard

Usage

Create a .php-cs-fixer.dist.php file in your project root:

<?php declare(strict_types=1);

require_once __DIR__.'/vendor/autoload.php';

use IWFWeb\CodingStandard\IWFWebStandardRiskySet;
use IWFWeb\CodingStandard\IWFWebStandardSet;
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

return new Config()
    ->registerCustomRuleSets([
        new IWFWebStandardSet(),
        new IWFWebStandardRiskySet(),
    ])
    ->setFinder(Finder::create()
        ->in(__DIR__)
    )
    ->setParallelConfig(ParallelConfigFactory::detect())
    ->setRiskyAllowed(true)
    ->setRules([
        '@IWFWeb/standard' => true,
        '@IWFWeb/standard:risky' => true,
    ])
;

Run the fixer:

# Check for violations (dry run)
vendor/bin/php-cs-fixer fix --dry-run --diff

# Fix violations
vendor/bin/php-cs-fixer fix

Rule Customizations

@IWFWeb/standard

Key customizations over the base @PhpCsFixer rule set:

  • No Yoda style - Uses natural comparison order ($value === null instead of null === $value)
  • Strict types at top - No blank line after opening tag to keep declare(strict_types=1); at the very top
  • Simplified class ordering - Only requires traits to be placed first in classes
  • Preserved DocBlocks - Single-line DocBlocks are preserved; @inheritDoc is not removed
  • Trailing commas everywhere - In arrays, arguments, parameters, and match expressions
  • PHPUnit flexibility - Does not require @covers annotations on test classes

@IWFWeb/standard:risky

Key customizations over the base @PhpCsFixer:risky rule set:

  • PHPUnit assertions - Uses self:: for test case static method calls
  • No forced strict types - Relies on PHPStan for type safety instead of enforcing declare(strict_types=1);
  • Flexible data providers - Does not enforce naming conventions for PHPUnit data providers
  • Ignored comment tags - Preserves php-cs-fixer-ignore and todo comments

Migration from v1.x

In v1.x, the namespace was IWF\CodingStandard with classes IWFSet and IWFRiskySet, and rule sets @IWF/standard and @IWF/standard:risky. These still work but are deprecated and will be removed in v2.0.

To migrate, update your .php-cs-fixer.dist.php:

-use IWF\CodingStandard\IWFRiskySet;
-use IWF\CodingStandard\IWFSet;
+use IWFWeb\CodingStandard\IWFWebStandardRiskySet;
+use IWFWeb\CodingStandard\IWFWebStandardSet;

 return new Config()
     ->registerCustomRuleSets([
-        new IWFSet(),
-        new IWFRiskySet(),
+        new IWFWebStandardSet(),
+        new IWFWebStandardRiskySet(),
     ])
     ->setRules([
-        '@IWF/standard' => true,
-        '@IWF/standard:risky' => true,
+        '@IWFWeb/standard' => true,
+        '@IWFWeb/standard:risky' => true,
     ])
 ;

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

This project uses Conventional Commits for automated releases and changelog generation.

Versioning

We use SemVer for versioning. For available versions, see the tags on this repository.

Authors

Special thanks for all the people who had helped this project so far

See also the full list of contributors who participated in this project.

I would like to join this list. How can I help the project?

We're currently looking for contributions for the following:

  • Bug fixes
  • Translations
  • etc...

For more information, please refer to our CONTRIBUTING.md guide.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Acknowledgments

This project currently uses no third-party libraries or copied code.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固