PHPackages                             mayflower/mo4-coding-standard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. mayflower/mo4-coding-standard

ActivePhpcodesniffer-standard[PSR &amp; Standards](/categories/psr-standards)

mayflower/mo4-coding-standard
=============================

PHP CodeSniffer ruleset implementing the MO4 coding standards extending the Symfony coding standards.

v11.0.2(2mo ago)17508.3k↓21.6%10[2 issues](https://github.com/mayflower/mo4-coding-standard/issues)[3 PRs](https://github.com/mayflower/mo4-coding-standard/pulls)5MITPHPPHP ^8.1CI failing

Since Oct 12Pushed 1mo ago12 watchersCompare

[ Source](https://github.com/mayflower/mo4-coding-standard)[ Packagist](https://packagist.org/packages/mayflower/mo4-coding-standard)[ Docs](https://github.com/mayflower/mo4-coding-standard)[ RSS](/packages/mayflower-mo4-coding-standard/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (30)Versions (38)Used By (5)

MO4 CodeSniffer ruleset
=======================

[](#mo4-codesniffer-ruleset)

Provides a PHP CodeSniffer ruleset for the MO4 coding standard

[![Build Status](https://github.com/mayflower/mo4-coding-standard/actions/workflows/ci.yml/badge.svg)](https://github.com/mayflower/mo4-coding-standard/actions)[![Code Coverage](https://camo.githubusercontent.com/ffa70b9a471481167929d262fffb3c86cea4d86d26250dc655be3fcda3a1e693/68747470733a2f2f636f6465636f762e696f2f67682f6d6179666c6f7765722f6d6f342d636f64696e672d7374616e646172642f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/mayflower/mo4-coding-standard/branch/master/)[![Qlty Maintainability](https://camo.githubusercontent.com/5dcfc6b09d339c125c9b59918b339f960ea605c8b47d61cbc45b3ca0faa9583b/68747470733a2f2f716c74792e73682f67682f6d6179666c6f7765722f70726f6a656374732f6d6f342d636f64696e672d7374616e646172642f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/mayflower/projects/mo4-coding-standard)[![SonarQube Maintainability](https://camo.githubusercontent.com/712eb57d6373da220d1611a07f2c7d75c5a97ed7534d0fa96809cef1da9ab176/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6d6179666c6f7765725f6d6f342d636f64696e672d7374616e64617264266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/dashboard?id=mayflower_mo4-coding-standard)

[![Latest Stable Version](https://camo.githubusercontent.com/29b1bd5317225e1c523c660e9bdbe54f0e70d4a0dff6d97db5c50432443f518b/68747470733a2f2f706f7365722e707567782e6f72672f6d6179666c6f7765722f6d6f342d636f64696e672d7374616e646172642f762f737461626c65)](https://packagist.org/packages/mayflower/mo4-coding-standard)[![Total Downloads](https://camo.githubusercontent.com/6f9e6c3a804dcac79a113ce43311ceb484787aef0f3bb64ebf32d508d097f6fe/68747470733a2f2f706f7365722e707567782e6f72672f6d6179666c6f7765722f6d6f342d636f64696e672d7374616e646172642f646f776e6c6f616473)](https://packagist.org/packages/mayflower/mo4-coding-standard)[![Latest Unstable Version](https://camo.githubusercontent.com/f4902c488bf6d15c892638e690bdace8fe631c9b3f11954a617c92f4400fb068/68747470733a2f2f706f7365722e707567782e6f72672f6d6179666c6f7765722f6d6f342d636f64696e672d7374616e646172642f762f756e737461626c65)](https://packagist.org/packages/mayflower/mo4-coding-standard)[![License](https://camo.githubusercontent.com/8add22eef38e75e3cc58d556169b28e3b733d39f692cab08a0a4462c7a488ddc/68747470733a2f2f706f7365722e707567782e6f72672f6d6179666c6f7765722f6d6f342d636f64696e672d7374616e646172642f6c6963656e7365)](https://packagist.org/packages/mayflower/mo4-coding-standard)[![composer.lock](https://camo.githubusercontent.com/bd55f18d9810d9292b5bd9190fdc80aaa782cc6c38995e13571ba15a4aa013cf/68747470733a2f2f706f7365722e707567782e6f72672f6d6179666c6f7765722f6d6f342d636f64696e672d7374616e646172642f636f6d706f7365726c6f636b)](https://packagist.org/packages/mayflower/mo4-coding-standard)

MO4 Coding Standard
-------------------

[](#mo4-coding-standard)

The MO4 Coding Standard is an extension of the [Symfony Coding Standard](http://symfony.com/doc/current/contributing/code/standards.html) and adds following rules:

### MO4.Arrays.ArrayDoubleArrowAlignment

[](#mo4arraysarraydoublearrowalignment)

- In associative arrays, the `=>` operators must be aligned.
- In arrays, the key and `=>` operator must be on the same line.

### MO4.Arrays.MultiLineArray

[](#mo4arraysmultilinearray)

- 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

[](#mo4commentingpropertycomment)

- doc blocks of class properties must be multiline and have exactly one `@var` annotation

### MO4.Formatting.AlphabeticalUseStatements

[](#mo4formattingalphabeticalusestatements)

- `use` statements must be sorted lexicographically. The order function can be configured.

#### Configuration

[](#configuration)

The `order` property of the `MO4.Formatting.AlphabeticalUseStatements` sniff defines which function is used for ordering.

Possible values for order:

- `dictionary` (default): based on [strcmp](http://php.net/strcmp), the namespace separator precedes any other character ```
    use Doctrine\ORM\Query;
    use Doctrine\ORM\Query\Expr;
    use Doctrine\ORM\QueryBuilder;
    ```
- `string`: binary safe string comparison using [strcmp](http://php.net/strcmp)```
    use Doctrine\ORM\Query;
    use Doctrine\ORM\QueryBuilder;
    use Doctrine\ORM\Query\Expr;

    use ExampleSub;
    use Examples;
    ```
- `string-locale`: locale based string comparison using [strcoll](http://php.net/strcoll)
- `string-case-insensitive`: binary safe case-insensitive string comparison [strcasecmp](http://php.net/strcasecmp)```
    use Examples;
    use ExampleSub;
    ```

To change the sorting order for your project, add this snippet to your custom `ruleset.xml`:

```

```

### MO4.Formatting.UnnecessaryNamespaceUsage

[](#mo4formattingunnecessarynamespaceusage)

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

### MO4.Strings.VariableInDoubleQuotedString

[](#mo4stringsvariableindoublequotedstring)

- Interpolated variables in double quoted strings must be surrounded by `{ }`, e.g. `{$VAR}` instead of `$VAR`.

### MO4.WhiteSpace.ConstantSpacing

[](#mo4whitespaceconstantspacing)

- const must be followed by a single space.

### MO4.WhiteSpace.MultipleEmptyLines

[](#mo4whitespacemultipleemptylines)

- No more than one empty consecutive line is allowed. Taken from [mediawiki/mediawiki-codesniffer](https://github.com/wikimedia/mediawiki-tools-codesniffer).

### Further rules (imported from other standards)

[](#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](http://symfony.com/doc/current/contributing/code/standards.html) 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
--------

[](#requires)

- [PHP](http://php.net)
- [Composer](https://getcomposer.org/) is optional, but strongly recommended

Installation
------------

[](#installation)

### Composer

[](#composer)

Using [Composer](https://getcomposer.org/) 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

[](#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
---------------

[](#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
------------

[](#dependencies)

- [PHP CodeSniffer](https://github.com/phpcsstandards/PHP_CodeSniffer)
- [David Joos's Symfony Coding Standard](https://github.com/djoos/Symfony-coding-standard)
- [Composer installer for PHP\_CodeSniffer coding standards](https://github.com/DealerDirect/phpcodesniffer-composer-installer)
- [Slevomat Coding Standard](https://github.com/slevomat/coding-standard)

Contributing
------------

[](#contributing)

See [CONTRIBUTING.md](.github/CONTRIBUTING.md) for information.

License
-------

[](#license)

This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for details.

###  Health Score

65

—

FairBetter than 99% of packages

Maintenance87

Actively maintained with recent releases

Popularity46

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 56.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~112 days

Recently: every ~57 days

Total

28

Last Release

64d ago

Major Versions

v7.0.0 → v8.0.02021-08-31

v8.0.0 → v9.0.02022-08-22

v8.0.1 → v10.0.02024-03-13

v10.0.2 → v11.0.02026-01-19

v10.0.3 → v11.0.22026-03-15

PHP version history (6 changes)v1.0.0PHP &gt;=5.4.0

v2.1.1PHP &gt;=5.6.0

v3.0.0PHP ~7.1

v6.0.0PHP ~7.2

v7.0.0PHP ~7.2 || ~8.0

v11.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f0574cd02f7aa226f0026cb4c027a92f36dd0a57d89ada829cee96fa4ccd13e?d=identicon)[xalopp](/maintainers/xalopp)

![](https://www.gravatar.com/avatar/7c999918d7436a090503d6bd37eb1a6a6e9009aaeaa9eabd8498241279058fb8?d=identicon)[Mayflower](/maintainers/Mayflower)

---

Top Contributors

[![mmoll](https://avatars.githubusercontent.com/u/1434927?v=4)](https://github.com/mmoll "mmoll (162 commits)")[![xalopp](https://avatars.githubusercontent.com/u/1674529?v=4)](https://github.com/xalopp "xalopp (106 commits)")[![Khartir](https://avatars.githubusercontent.com/u/5592420?v=4)](https://github.com/Khartir "Khartir (6 commits)")[![Ma27](https://avatars.githubusercontent.com/u/6025220?v=4)](https://github.com/Ma27 "Ma27 (4 commits)")[![calbrecht](https://avatars.githubusercontent.com/u/1516457?v=4)](https://github.com/calbrecht "calbrecht (4 commits)")[![ritters](https://avatars.githubusercontent.com/u/2544235?v=4)](https://github.com/ritters "ritters (2 commits)")[![groxxda](https://avatars.githubusercontent.com/u/5701271?v=4)](https://github.com/groxxda "groxxda (1 commits)")[![nremez](https://avatars.githubusercontent.com/u/1303877?v=4)](https://github.com/nremez "nremez (1 commits)")[![elseym](https://avatars.githubusercontent.com/u/907478?v=4)](https://github.com/elseym "elseym (1 commits)")

---

Tags

codesniffercoding-standardhacktoberfestphpphp-codesnifferqasymfonypsrstandardsphpcssymfonystatic analysismo4

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mayflower-mo4-coding-standard/health.svg)

```
[![Health](https://phpackages.com/badges/mayflower-mo4-coding-standard/health.svg)](https://phpackages.com/packages/mayflower-mo4-coding-standard)
```

###  Alternatives

[automattic/vipwpcs

PHP\_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions

25510.2M145](/packages/automattic-vipwpcs)[yoast/yoastcs

PHP\_CodeSniffer rules for Yoast projects

221.1M29](/packages/yoast-yoastcs)[drupal/coder

Coder is a library to review Drupal code.

3043.6M461](/packages/drupal-coder)[orisai/coding-standard

Strict PHP coding standard

19193.5k62](/packages/orisai-coding-standard)[phpcompatibility/phpcompatibility-all

A set of rulesets for PHP\_CodeSniffer to check for PHP cross-version compatibility issues and opportunities to modernize code in PHP projects.

1361.7k](/packages/phpcompatibility-phpcompatibility-all)[infinum/eightshift-coding-standards

Eightshift WordPress Coding Standards

1785.2k3](/packages/infinum-eightshift-coding-standards)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
