All Projects → mayflower → Mo4 Coding Standard

mayflower / Mo4 Coding Standard

Licence: mit
MO4 Coding Standard Rules for Codesniffer based on Symfony Coding Standards.

Projects that are alternatives of or similar to Mo4 Coding Standard

Phpqa
Docker image that provides static analysis tools for PHP
Stars: ✭ 853 (+5586.67%)
Mutual labels:  php-codesniffer, qa
Symfony Coding Standard
Development repository for the Symfony coding standard
Stars: ✭ 381 (+2440%)
Mutual labels:  php-codesniffer, symfony
Symplify
Do you use Symfony, Coding Standards, maintain PHP packages, automate monorepo, generate static website and are you lazy? You'll love the candies you find here! :)
Stars: ✭ 430 (+2766.67%)
Mutual labels:  php-codesniffer, symfony
Frankie
A frankenstein framework - middleware and annotation based
Stars: ✭ 19 (+26.67%)
Mutual labels:  symfony
Influxdb Bundle
Bundle service integration of official influxdb/influxdb-php client
Stars: ✭ 24 (+60%)
Mutual labels:  symfony
Sendgrid Mailer
Provides Sendgrid integration for Symfony Mailer
Stars: ✭ 24 (+60%)
Mutual labels:  symfony
Routing
The Routing component maps an HTTP request to a set of configuration variables.
Stars: ✭ 7,080 (+47100%)
Mutual labels:  symfony
Admincrudbundle
AdminCrud genera un controlador muy básico para una Entity dada. Este controlador extiende e implementa un controlador Super Genial.
Stars: ✭ 18 (+20%)
Mutual labels:  symfony
Api Example
WIP: Just sample app with API
Stars: ✭ 12 (-20%)
Mutual labels:  symfony
Process
The Process component executes commands in sub-processes.
Stars: ✭ 6,942 (+46180%)
Mutual labels:  symfony
Css Selector
The CssSelector component converts CSS selectors to XPath expressions.
Stars: ✭ 6,928 (+46086.67%)
Mutual labels:  symfony
Migrify
Futuristic Grinder for Legacy Code with Effortles Confidence
Stars: ✭ 25 (+66.67%)
Mutual labels:  symfony
Polyfill Xml
This polyfill is deprecated. Use the symfony/polyfill-php72 package instead.
Stars: ✭ 11 (-26.67%)
Mutual labels:  symfony
Bdd Experiment
An experiment on BDD in Symfony2 using Behat, Mink and Zombie.js
Stars: ✭ 12 (-20%)
Mutual labels:  symfony
Syliusmercanetbnpparibasplugin
BnpParibas Mercanet payment gateway for Sylius based applications.
Stars: ✭ 12 (-20%)
Mutual labels:  symfony
Symfony Crawler Bundle
Implements the crawler package into Symfony
Stars: ✭ 8 (-46.67%)
Mutual labels:  symfony
Stagy
Stagy is a tool for quick deployment of staging environments.
Stars: ✭ 19 (+26.67%)
Mutual labels:  qa
Nlp tensorflow project
Use tensorflow to achieve some NLP project, eg: classification chatbot ner attention QAetc.
Stars: ✭ 27 (+80%)
Mutual labels:  qa
Accompli
An easy to use and extendable deployment tool for (PHP) projects.
Stars: ✭ 9 (-40%)
Mutual labels:  symfony
Rechko
Software for a universal dictionary in Bulgarian.
Stars: ✭ 13 (-13.33%)
Mutual labels:  symfony

MO4 CodeSniffer ruleset

Provides a PHP CodeSniffer ruleset for the MO4 coding standard

Build Status Code Coverage Scrutinizer Quality Level 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.AlphabeticalUseStatements

  • use statements must be sorted lexicographically, grouped by empty lines. The order function can be configured.

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, 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
    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
  • string-case-insensitive: binary safe case-insensitive string comparison strcasecmp
    use Examples;
    use ExampleSub;
    

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

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

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

  • PHP version 7.1 or later
  • Composer is optional, but strongly recommended

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].