algoritma/php-coding-standards 问题修复 & 功能扩展

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

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

algoritma/php-coding-standards

Composer 安装命令:

composer require algoritma/php-coding-standards

包简介

A usefull PHP Coding Standard for your projects, based on PHPStan, PHP CS Fixer and Rector.

README 文档

README

Version PHP version supported
3.0 >= 8.1

Installation

To install the coding standard, run the following command:

$ composer require --dev algoritma/php-coding-standards

When you install it, a plugin will ask you some questions to setup your project automatically.

The installer will add the .php-cs-fixer.dist.php, rector.php, and phpstan.neon files in your project root directory. You can then edit them manually if you need to make any changes.

The CS config will be configured to find your project files using composer autoload sources. Only psr-0, psr-4 and classmap autoloads are supported.

The installer will also add five scripts in your composer.json;

"scripts": {
    "cs-check": "php-cs-fixer fix --dry-run --diff --allow-risky yes",
    "cs-fix": "php-cs-fixer fix --diff --allow-risky yes",
    "rector-check": "rector process --dry-run",
    "rector-fix": "rector process",
    "phpstan": "phpstan analyze"
}

Usage

To start code style check:

$ composer cs-check

To automatically fix code style:

$ composer cs-fix

To automatically check for refactor:

$ composer rector-check

To automatically refactor fix:

$ composer rector-fix

To run static analisys check:

$ composer phpstan

Configuration Generation

If you need to regenerate the default configuration files, use the following commands:

To regenerate the default .php-cs-fixer.dist.php configuration:

$ composer algoritma-cs-create-config
$ composer algoritma-cs-create-config --help

Usage:
  algoritma-cs-create-config [options]

Options:
      --no-dev                   Do not include autoload-dev directories
      --no-risky                 Do not include risky rules

To regenerate the default rector.php configuration:

$ composer algoritma-rector-create-config
$ composer algoritma-rector-create-config --help

Usage:
  algoritma-rector-create-config [options]

Options:
      --no-dev                   Do not include autoload-dev directories

To regenerate the default phpstan.neon configuration:

$ composer algoritma-phpstan-create-config
$ composer algoritma-phpstan-create-config --help

Usage:
  algoritma-phpstan-create-config [options]

Options:
      --no-dev                   Do not include autoload-dev directories

Main Dependencies

This project relies on the following tools to enforce coding standards:

Configuration

For more information on how to configure the tools, please refer to their official documentation.

Risky rules (PHP-CS-Fixer)

Risky rules may be unstable, and cause unintended behavioral changes to your code. If you want to add these rules, you can create your own .php-cs-fixer.php configuration:

<?php

/** @var \PhpCsFixer\Config $config */
$config = include __DIR__ . '/.php-cs-fixer.dist.php';

$rulesProvider = new Algoritma\CodingStandards\Rules\CompositeRulesProvider([
    new Algoritma\CodingStandards\Rules\DefaultRulesProvider(),
    new Algoritma\CodingStandards\Rules\RiskyRulesProvider(),
    new Algoritma\CodingStandards\Rules\ArrayRulesProvider([
        // additional rules or rules to override
    ]),
]);

$config->setRules($rulesProvider->getRules());

return $config;

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-12-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固