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

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

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

paysera/lib-php-cs-fixer-config

Composer 安装命令:

composer require paysera/lib-php-cs-fixer-config

包简介

PHP CS Fixer config for Paysera conventions

README 文档

README

Library helps to fix PHP code to conform Paysera PHP style guide.

Installation

Prerequisite

  • Add Paysera\\PhpCsFixerConfig\\Composer\\PhpCsFixerConfigProvider::copyPhpCs script to post-install-cmd and post-update-cmd or other scripts - just make sure this script is executed on composer install.

Install and check

  • composer require --dev paysera/lib-php-cs-fixer-config.
  • Make sure php-cs-fixer.php file is in project directory.

No need to install php-cs-fixer itself as this library comes with binary version of the fixer. This avoids requiring its dependencies inside your project, which could clash with existing ones.

To avoid duplication with php-cs-fixer library, it's named paysera-php-cs-fixer.

php-cs-fixer.php files
  • php-cs-fixer.php - all Paysera recommended fixers.
  • php-cs-fixer-risky.php - all risky fixers except recommendations (comment warnings).
  • php-cs-fixer-safe.php - all non risky fixers.

Migration mode

For new projects you can just use all the rules as usual.

For existing projects we recommend turning on the migration mode:

  1. Add call to enableMigrationMode([]) to PayseraConventionsConfig instance in your php-cs-fixer.php file.
  2. Run {your-bin-dir}/php-cs-fixer - it will give error with initial rule configuration to pass into that method. Just copy-and-paste it to your php-cs-fixer.php file.
  3. Enable one of the rules, apply fixes in the project, review and test them.
  4. Repeat with each new rule.

This allows to control which rules are enabled in the project thus letting manually tune the fixes already applied in the repository and forced for the new code. Also, your commits will be more focused as each of them will include only changes from a single fixer.

All rules are to be configured to allow easily spotting new rules in case they would be added (or removed) into the core.

Running fixer with tests

For comments or suggestions for developers you should use default php-cs-fixer.php file with all the rules.

For automatic checks there might be some false-positives so php-cs-fixer-risky.php should be used in such cases.

You can look at .travis.yml file in this repository for integration with travis on each pull request of your repository (this will run the checks only for changed files).

Usage

Run in project directory by command: {your-bin-dir}/php-cs-fixer fix /path/to/code --verbose --dry-run --diff

Use --config=php-cs-fixer.php flag for custom configuration.

If /path/to/code is not defined php-cs-fixer will run files from default src directory excluding Test folders.

--verbose - show the applied rules. When using the txt format it will also display progress notifications.

A combination of --dry-run and --diff will display a summary of proposed fixes, leaving your files unchanged.

--format option for the output format. Supported formats are txt (default one), json, xml and junit.

More information: PHP CS Fixer

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 10
  • Watchers: 7
  • Forks: 19
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-08-08