定制 romanzipp/php-cs-fixer-config 二次开发

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

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

romanzipp/php-cs-fixer-config

Composer 安装命令:

composer require romanzipp/php-cs-fixer-config

包简介

Personal PHP-CS-Fixer Configuration

README 文档

README

Latest Stable Version Total Downloads License GitHub Build Status

Personal PHP-CS-Fixer wrapper, preset management and custom rules.

Installation

composer require romanzipp/php-cs-fixer-config --dev

Notice: You also need to install the PHP-CS-Fixer package itself if you need a local installation with executable in your vendor/bin folder.

Usage

This package has been created to streamline configuration management for multiple projects and keeping PHP CS Fixer rules up to date.

.php-cs-fixer.dist.php

return romanzipp\Fixer\Config::make()
    ->in(__DIR__)
    ->preset(
        new romanzipp\Fixer\Presets\PrettyPHP()
    )
    ->out();

Available Presets

You can easily create your own presets by extending the AbstractPreset class.

Overriding presets

In case you only need some tweaks for specific projects - which won't deserve an own preset - there are various methods you can make us of.

$config = romanzipp\Fixer\Config::make();

$config->allowRisky(true);                  // Allow risky rules.
$config->withRules(['...']);                // Set additional rules
$config->exclude(['...']);                  // Add single or many files to the list of excluded files.
$config->excludeDirectories(['...']);       // Add single or many directories to the list of excluded directories.

Available Rules

Convert PHPDoc Classes to FQCN

$fixer->withRules([
    'RomanZipp/phpdoc_fqcn' => true,
]);
Show code sample

Bad

use App\Foo;
use App\Bar;

/**
 * @param  Foo $foo
 * @return Bar[]  
 */
function foo(Foo $foo): array {}

Good

use App\Foo;

/**
 * @param  \App\Foo $foo
 * @return \App\Bar[]  
 */
function foo(Foo $foo): array {}

Advanced Usage

Access the config and finder instances

return romanzipp\Fixer\Config::make()
    // ...
    ->finderCallback(static function (PhpCsFixer\Finder $finder): void {
        // ...
    })
    ->configCallback(static function (PhpCsFixer\Config $config): void {
        $config->registerCustomFixers();
        // ...
    })
    // ...
    ->out();

PHPStorm Configuration

Prequisites

You will need to install PHP CS Fixer globally on your system because PHPStorm does not allow you to set the php-cs-fixer executable on a per-project basis or relative to the project path.

composer global require friendsofphp/php-cs-fixer

1. Enable Inspection

2. Select ruleset .php-cs-fixer.dist.php file [...]

Unfortunately you have to repeat this process for every project since there is a bug in PHPStorm which prevents users from using relative paths for the .php-cs-fixer.dist.php configuration or executable file.

Another theoretical approach to this issue is to create a unified ruleset file in your users .composer folder. This has the downside on only having one single ruleset.

3. Navigate to Quality Tools by clicking on the "PHP CS Fixer" link

4. Select PHP-CS-Fixer executable

romanzipp/php-cs-fixer-config 适用场景与选型建议

romanzipp/php-cs-fixer-config 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42.45k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2021 年 01 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 romanzipp/php-cs-fixer-config 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-15