承接 hks-systeme/php-cs-fixer-config 相关项目开发

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

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

hks-systeme/php-cs-fixer-config

最新稳定版本:2.9.0

Composer 安装命令:

composer require hks-systeme/php-cs-fixer-config

包简介

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

README 文档

README

Integrate Merge Prune Release Renew Triage

Code Coverage Type Coverage

Latest Stable Version Total Downloads

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

Installation

Run

$ composer require --dev hks-systeme/php-cs-fixer-config

Usage

Configuration

Pick one of the rule sets:

Create a configuration file .php-cs-fixer.php in the root of your project:

<?php use HKS\PhpCsFixer\Config; $config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74()); $config->getFinder()->in(__DIR__); $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache'); return $config;

Git

All configuration examples use the caching feature, and if you want to use it as well, you should add the cache directory to .gitignore:

+ /.build/ /vendor/

???? Personally, I prefer to use a .build directory for storing build artifacts.

Configuration with header

???? Optionally specify a header:

 <?php use HKS\PhpCsFixer\Config; +$header = <<<EOF +Copyright (c) 2021 HKS Systeme GmbH + +For the full copyright and license information, please view +the LICENSE file that was distributed with this source code. + +@see https://github.com/hks-systeme/php-cs-fixer-config +EOF; -$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74()); +$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74($header)); $config->getFinder()->in(__DIR__); $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache'); return $config;

This will enable and configure the HeaderCommentFixer, so that file headers will be added to PHP files, for example:

<?php /**  - Copyright (c) 2021 HKS Systeme GmbH  *  - For the full copyright and license information, please view  - the LICENSE file that was distributed with this source code.  *  - @see https://github.com/hks-systeme/php-cs-fixer-config  */

Configuration with override rules

???? Optionally override rules from a rule set by passing in an array of rules to be merged in:

 <?php use HKS\PhpCsFixer\Config; -$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74()); +$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74(), [ + 'mb_str_functions' => false, + 'strict_comparison' => false, +]); $config->getFinder()->in(__DIR__); $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache'); return $config;

Makefile

If you like Makefiles, create a Makefile with a coding-standards target:

+.PHONY: coding-standards +coding-standards: vendor + mkdir -p .build/php-cs-fixer + vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose vendor: composer.json composer.lock composer validate composer install

Run

$ make coding-standards 

to automatically fix coding standard violations.

Composer script

If you like composer scripts, add a coding-standards script to composer.json:

 { "name": "foo/bar", "require": { "php": "^7.4", }, "require-dev": { "hks-systeme/php-cs-fixer-config": "~1.0.0" + }, + "scripts": { + "coding-standards": [ + "mkdir -p .build/php-cs-fixer", + "php-cs-fixer fix --diff --verbose" + ] } }

Run

$ composer coding-standards 

to automatically fix coding standard violations.

GitHub Actions

If you like GitHub Actions, add a coding-standards job to your workflow:

 on: pull_request: null push: branches: - main name: "Integrate" jobs: + coding-standards: + name: "Coding Standards" + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: + - "7.4" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP with extensions" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2" + with: + path: "~/.composer/cache" + key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-" + + - name: "Install locked dependencies with composer" + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Create cache directory for friendsofphp/php-cs-fixer" + run: mkdir -p .build/php-cs-fixer + + - name: "Cache cache directory for friendsofphp/php-cs-fixer" + uses: "actions/cache@v2" + with: + path: "~/.build/php-cs-fixer" + key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.sha }}" + restore-keys: "php-${{ matrix.php-version }}-php-cs-fixer-" + + - name: "Run friendsofphp/php-cs-fixer" + run: "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --dry-run --verbose"

Changelog

Please have a look at CHANGELOG.md.

Contributing

Please have a look at .github/CONTRIBUTING.md.

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md.

License

This package is licensed using the MIT License.

Please have a look at LICENSE.md.

Credits

This project is inspired by ergebnis/php-cs-fixer-config.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固