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::copyPhpCsscript topost-install-cmdandpost-update-cmdor otherscripts- just make sure this script is executed oncomposer install.
Install and check
composer require --dev paysera/lib-php-cs-fixer-config.- Make sure
php-cs-fixer.phpfile 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:
- Add call to
enableMigrationMode([])toPayseraConventionsConfiginstance in yourphp-cs-fixer.phpfile. - 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 yourphp-cs-fixer.phpfile. - Enable one of the rules, apply fixes in the project, review and test them.
- 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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 34.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 14
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-08-08