Contains PHP coding standards like rules for PHP-CS-Fixer that serves for purpose of standardization.

v2.0.0 2021-09-07 09:34 UTC

This package is auto-updated.

Last update: 2021-10-07 09:54:28 UTC


Contains PHP coding standards like rules for PHP-CS-Fixer that serves for purpose of standardization.


composer require --dev  mollie/php-coding-standards


This package makes use of PHP-CS-Fixer.

Already familiar with PHP-CS-Fixer

This package provides default rules to be used with PHP-CS-Fixer.

You can find them in Mollie\PhpCodingStandards\PhpCsFixer\Rules which has methods specific to php version, which you can directly use in the ->setRules() part of your config. For example, assuming PHP version 7.3:

use Mollie\PhpCodingStandards\PhpCsFixer\Rules;


New to PHP-CS-Fixer

Place a file named .php-cs-fixer.dist.php that has the following content in your project's root directory.


use Mollie\PhpCodingStandards\PhpCsFixer\Rules;
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()

return (new Config())
    // use specific rules for your php version e.g.: getForPhp71, getForPhp72, getForPhp73

Manual Triggering

Run following command in your project directory, that will run fixer for every .php file.

vendor/bin/php-cs-fixer fix

Use via PhpStorm file watcher

Please follow official PhpStorm documentation

Use via pre-commit git hook

Place a file with the content of the following bash script into .git/hooks directory called pre-commit and make it executable you can find more details about git hooks on official git manual.

#!/usr/bin/env bash

git diff --diff-filter=ACMRTUXB --name-only --staged | grep -E '\.php(_cs\.dist)?$' | grep -vE $EXCLUDE_DIRECTORIES_REGEX |  while read FILE; do
    STATUS="$(git status --porcelain ${FILE} | cut -c 1-2)"
    vendor/bin/php-cs-fixer fix --using-cache=no --quiet --dry-run ${FILE}

    # Not 0 means php-cs-fixer either errored or wanted to make changes
    if [ $? != 0 ]
        # MM = staged & non-staged modification in same file
        if [ ${STATUS} = "MM" ]
            echo -e "\033[31m┌────────────────────────────────────────────────────────────────────────────────┐"
            echo -e "│ Failure:\033[39m Codestyle violation(s) in file with both staged and unstaged changes. \033[31m│"
            echo -e "├────────────────────────────────────────────────────────────────────────────────┘"
            echo -e "└\033[33m File:\033[39m    $FILE"
            exit 1

        vendor/bin/php-cs-fixer fix --using-cache=no --quiet ${FILE}
        git add ${FILE}

Working at Mollie

Mollie is always looking for new talent to join our teams. We’re looking for inquisitive minds with good ideas and strong opinions, and, most importantly, who know how to ship great products. Want to join the future of payments? Check out our vacancies.


BSD (Berkeley Software Distribution) License. Copyright (c) 2019, Mollie B.V.