Coding Standards (PHPCS and PHPMD)

Automated testing doesn’t mean just functionality — code quality and looks are important too! WordPress coding standards are enforced using the popular PHP CodeSnifferarrow-up-right tool and code quality is being continuously checked using the PHP Mess Detectorarrow-up-right rules. The custom rules used by DWS are present in the phpcs.xml.dist and phpmd.xml.dist files in each public project on GitHubarrow-up-right.

Basically, this ensures that a few WordPress-specific errors can never occur as long as the tests pass. Here are some examples:

  • All output is ran through an escaping function.

  • All user input is ran through a sanitization function.

  • All translatable strings use the same language domain.

  • All global functions/variables/classes are prefixed properly.

Last updated