定制 mayflower/mo4-coding-standard 二次开发

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

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

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

Build Status Code Coverage Qlty Maintainability SonarQube Maintainability

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

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 @var annotation

MO4.Formatting.UnnecessaryNamespaceUsage

  • The imported class name must be used, when it was imported with a use statement.

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

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.

  1. Add the MO4 coding standard to composer.json

     composer require --dev mayflower/mo4-coding-standard
    
  2. Profit

     ./vendor/bin/phpcs --standard=MO4 path/to/my/file.php
    
  3. Optionally, you might set MO4 as default coding standard

     ./vendor/bin/phpcs --config-set default_standard MO4
    

Source

  1. Checkout this repository

     git clone https://github.com/mayflower/mo4-coding-standard.git
    
  2. Install dependencies

     composer install
    
  3. Check, that Symfony and MO4 are listed as coding standards

     ./vendor/bin/phpcs -i
    
  4. Profit

     ./vendor/bin/phpcs --standard=MO4 path/to/my/file.php
    
  5. 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

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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 17
  • Watchers: 12
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-23