mayflower/mo4-coding-standard
Composer 安装命令:
composer require --dev mayflower/mo4-coding-standard
包简介
PHP CodeSniffer ruleset implementing the MO4 coding standards extending the Symfony coding standards.
README 文档
README
Provides a PHP CodeSniffer ruleset for the MO4 coding standard
MO4 Coding Standard
The MO4 Coding Standard is an extension of the Symfony Coding Standard and adds following rules:
MO4.Arrays.ArrayDoubleArrowAlignment
- In associative arrays, the
=>operators must be aligned. - In arrays, the key and
=>operator must be on the same line.
MO4.Arrays.MultiLineArray
- In multi line arrays, the opening bracket must be followed by newline.
- In multi line arrays, the closing bracket must be in own line.
- In multi line arrays, the elements must be indented.
MO4.Commenting.PropertyComment
- doc blocks of class properties must be multiline and have exactly one
@varannotation
MO4.Formatting.UnnecessaryNamespaceUsage
- The imported class name must be used, when it was imported with a
usestatement.
MO4.Strings.VariableInDoubleQuotedString
- Interpolated variables in double quoted strings must be surrounded by
{ }, e.g.{$VAR}instead of$VAR.
MO4.WhiteSpace.ConstantSpacing
- const must be followed by a single space.
MO4.WhiteSpace.MultipleEmptyLines
- No more than one empty consecutive line is allowed. Taken from mediawiki/mediawiki-codesniffer.
Further rules (imported from other standards)
- See
MO4/ruleset.xml, which has each imported rule commented.
Note that with this ruleset, the following Symfony Coding Standard rules are not enforced:
- "
add doc blocks for all classes": the doc block for classes can be omitted, if they add no value - "
the license block has to be present at the top of every PHP file, before the namespace": the license block can be omitted
Most of the issues can be auto-fixed with phpcbf.
Requires
Installation
Composer
Using Composer is the preferred way.
-
Add the MO4 coding standard to
composer.jsoncomposer require --dev mayflower/mo4-coding-standard -
Profit
./vendor/bin/phpcs --standard=MO4 path/to/my/file.php -
Optionally, you might set MO4 as default coding standard
./vendor/bin/phpcs --config-set default_standard MO4
Source
-
Checkout this repository
git clone https://github.com/mayflower/mo4-coding-standard.git -
Install dependencies
composer install -
Check, that Symfony and MO4 are listed as coding standards
./vendor/bin/phpcs -i -
Profit
./vendor/bin/phpcs --standard=MO4 path/to/my/file.php -
Optionally, you might set MO4 as default coding standard
./vendor/bin/phpcs --config-set default_standard MO4
Troubleshooting
If phpcs complains that MO4 is not installed, please check the installed coding standards with
phpcs -i and that installed_paths is set correctly with phpcs --config-show
Dependencies
- PHP CodeSniffer
- David Joos's Symfony Coding Standard
- Composer installer for PHP_CodeSniffer coding standards
- Slevomat Coding Standard
Contributing
See CONTRIBUTING.md for information.
License
This project is licensed under the MIT license. See the LICENSE file for details.
mayflower/mo4-coding-standard 适用场景与选型建议
mayflower/mo4-coding-standard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 538.25k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2017 年 11 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「static analysis」 「standards」 「phpcs」 「psr」 「mo4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mayflower/mo4-coding-standard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mayflower/mo4-coding-standard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mayflower/mo4-coding-standard 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
The bundle for easy using json-rpc api on your project
TwigStan is a static analyzer for Twig templates powered by PHPStan
Sentiment analysis library for PHP.
Database Standardization and Analysis Tool for Laravel
Enforce architecture by defining modules with allowed dependencies. Detects forbidden, uncovered, missing and unused module dependencies in PHP projects.
统计信息
- 总下载量: 538.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 21
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-23