2017 © Pedro Peláez
 

phpcodesniffer-standard mo4-coding-standard

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

image

mayflower/mo4-coding-standard

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

  • Friday, July 27, 2018
  • by xalopp
  • Repository
  • 14 Watchers
  • 12 Stars
  • 2,636 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 3 Open issues
  • 7 Versions
  • 108 % Grown

The README.md

MO4 CodeSniffer ruleset

Provides a PHP CodeSniffer ruleset for the MO4 coding standard, (*1)

Build Status Code Coverage Scrutinizer Quality Level Codeclimate Maintainability SonarQube Maintainability, (*2)

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock, (*3)

MO4 Coding Standard

The MO4 Coding Standard is an extension of the Symfony Coding Standard and adds following rules:, (*4)

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.AlphabeticalUseStatements

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

Configuration

The order property of the MO4.Formatting.AlphabeticalUseStatements sniff defines which function is used for ordering., (*5)

Possible values for order: * dictionary (default): based on strcmp, the namespace separator precedes any other character php use Doctrine\ORM\Query; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\QueryBuilder; * string: binary safe string comparison using strcmp ```php use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\Query\Expr;, (*6)

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)php use Examples; use ExampleSub; ```, (*7)

To change the sorting order for your project, add this snippet to your custom ruleset.xml:, (*8)

<rule ref="MO4.Formatting.AlphabeticalUseStatements">
    <properties>
        <property name="order" value="string-locale"/>
    </properties>
</rule>

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, (*9)

Most of the issues can be auto-fixed with phpcbf., (*10)

Requires

Installation

Composer

Using Composer is the preferred way., (*11)

  1. Add the MO4 coding standard to composer.json, (*12)

    composer require --dev mayflower/mo4-coding-standard
  2. Profit, (*13)

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

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

Source

  1. Checkout this repository, (*15)

    git clone https://github.com/mayflower/mo4-coding-standard.git
  2. Install dependencies, (*16)

    composer install
  3. Check, that Symfony and MO4 are listed as coding standards, (*17)

    ./vendor/bin/phpcs -i
  4. Profit, (*18)

    ./vendor/bin/phpcs --standard=MO4 path/to/my/file.php
  5. Optionally, you might set MO4 as default coding standard, (*19)

    ./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, (*20)

Dependencies

Contributing

See CONTRIBUTING.md for information., (*21)

License

This project is licensed under the MIT license. See the LICENSE file for details., (*22)

The Versions

27/07 2018

dev-master

9999999-dev https://github.com/mayflower/mo4-coding-standard

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Xaver Loppenstedt

psr phpcs symfony standards mo4

17/05 2018

v2.1.1

2.1.1.0 https://github.com/mayflower/mo4-coding-standard

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Xaver Loppenstedt

psr phpcs symfony standards mo4

06/04 2018

v2.1.0

2.1.0.0 https://github.com/mayflower/mo4-coding-standard

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Xaver Loppenstedt

psr phpcs symfony standards mo4

15/12 2017

v2.0.0

2.0.0.0 https://github.com/mayflower/mo4-coding-standard

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Xaver Loppenstedt

psr phpcs symfony standards mo4

19/11 2017

v1.0.0

1.0.0.0 https://github.com/mayflower/mo4-coding-standard

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Xaver Loppenstedt

psr phpcs symfony standards mo4

12/10 2017

2.9.x-dev

2.9.9999999.9999999-dev https://github.com/mayflower/mo4-coding-standard

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Xaver Loppenstedt

psr phpcs symfony standards mo4

23/09 2015

dev-blank_line_before_control_structure

dev-blank_line_before_control_structure https://github.com/Mayflower/mo4-coding-standard

PHP_CodeSniffer ruleset for Symfony PSR coding standards.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Xaver Loppenstedt

psr phpcs symfony standards