Skip to content

Coding standards

Robbie Averill edited this page Jan 7, 2017 · 2 revisions

SilverLeague modules all follow the PSR-2 coding style guide.

This includes, but is not limited to:

  • Namespacing
  • One class per file
  • Correct class naming
  • Correct function naming*
  • Spaces for indentation
  • Class and function braces on new lines
  • PHPDoc documentation for all functions, class properties and constants

*: Exceptions made for where incorrect naming conventions are required by the SilverStripe framework.

PHP Code Sniffer

We enforce that our code meets PSR-2 compatibility by running PHP Code Sniffer checks in our continuous integration environments.

SilverLeague projects will have a phpcs.xml.dist file which specifies the folder paths and PSR-2 as the standard to check. If you want to override this configuration with a custom file you can create phpcs.xml which will take priority, or provide the --standard=/path/to/phpcs.xml argument to phpcs.

Please see the Templates page for an example file template.

Clone this wiki locally