Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
MO4 Coding Standard Rules for Codesniffer based on Symfony Coding Standards.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

MO4 CodeSniffer ruleset

Provides a CodeSniffer ruleset

  • MO4 standard


MO4 Coding Standard

The MO4 Coding Standard is an extension of the Symfony Coding Standard and adds following rules:

  • short tags "[...]" must be used instead of "array(...)",
  • in associates arrays, the "=>" operators must be aligned,
  • in arrays, the key and '=>' operator must be on the same line.
  • each consecutive variable assignements must align on the assigment operator,
  • use statements must be sorted,
  • you should use the imported class name, whenever it was imported with a use statement,
  • variables in double quoted strings must be surrounded by { }, e.g. "{$VAR}" instead of "$VAR",
  • sprintf or "{$VAR1} {$VAR2}" must be used instead of the concat operator, concat opetor are only allowed to concat constant an multi line strings,
  • a white space is requried after each cast opetor, e.g. "(int) $value" instead of "(int)$value",


  1. Install phpcs:

    pear install PHP_CodeSniffer
  2. Find your PEAR directory:

    pear config-show | grep php_dir
  3. Copy, symlink or check out this repo to a folder called Symfony inside the phpcs Standards directory:

    cd /path/to/pear/PHP/CodeSniffer/Standards
    git clone git:// Symfony
    git clone git:// MO4
  4. Select the Symfony ruleset as your default coding standard:

    phpcs --config-set default_standard MO4
  5. Profit

    phpcs path/to/my/file.php


If you contribute code to these sniffs, please make sure it conforms to the PHPCS coding standard and that the unit tests still pass.

To check the coding standard, run from the Symfony-coding-standard source root:

    phpcs --ignore=Tests --standard=PHPCS . -n

The unit-tests are run from within the PHP_CodeSniffer directory

  • get the CodeSniffer repository
  • get the Symfony Coding Standard and symlink, copy or clone it at CodeSniffer/Standards/Symfony
  • symlink, copy or clone this repository at CodeSniffer/Standards/MO4
  • from the CodeSniffer repository root run phpunit --filter Symfony_ tests/AllTests.php



This project is licensed under the MIT license.

Something went wrong with that request. Please try again.