Coding standards definition compatible with PSR-2

v9.1.1 2021-04-09 14:02 UTC

This package is auto-updated.

Last update: 2021-06-10 08:16:27 UTC


Build Status Downloads

Shopsys Coding Standards are based on PSR-2.

This project bundles tools along with predefined rulesets for automated checks of Shopsys Coding Standards that we use in many Shopsys projects. The repository also contains few custom rules.

This repository is maintained by shopsys/shopsys monorepo, information about changes is in monorepo

Provided tools:

For further information see official documentation of those tools.


php composer require shopsys/coding-standards


Create easy-coding-standard.yml config file in your project which includes predefined ruleset. You can also customize the rules and even add your own sniffs and fixers in the config.

   - { resource: '%vendor_dir%/shopsys/coding-standards/easy-coding-standard.yml' }

In terminal, run following commands:

php vendor/bin/parallel-lint /path/to/project
php vendor/bin/ecs check /path/to/project --config=/path/to/project/custom-coding-standard.yml

Custom rules

Rules for PHP-CS-Fixer


All <button> HTML tags in .html and .html.twig files must have explicit type attribute.

If the type is not specified it will be fixed to type="button"" because the implicit value is submit which makes it behave differently based on the context (<button> inside <form> element submits the form).


Doctrine annotations @ORM\ManyToOne and @ORM\OneToOne must have nullable option defined explicitly in @ORM\JoinColumn.

If the nullable option is not specified it will be fixed to nullable=false because the implicit value is true but this is the opposite to the implicit value of nullable for @Column annotation. This makes it consistent.

Rules for PHP_CodeSniffer


Function exit() is not allowed.


Usage of superglobals ($_COOKIE, $_GET, $_FILES, $_POST, $_REQUEST, $_SERVER) is not allowed.


Instantiation of objects that can be created by their factories is not allowed outside of the factory.


Default \PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidVariableNameSniff does not report method parameters in $_var format as an violation but it should. It also skips checking of private members when PrivateNoUnderscore property is disabled.

This sniff provides the missing functionality and is intended to be used as an addition to the default ValidVariableNameSniff.


Thank you for your contributions to Shopsys Coding Standards package. Together we are making Shopsys Framework better.

This repository is READ-ONLY. If you want to report issues and/or send pull requests, please use the main Shopsys repository.

Please, check our Contribution Guide before contributing.


What to do when you are in troubles or need some help? Best way is to contact us on our Slack

If you want to report issues, please use the main Shopsys repository.