Continuous integration/PHP CodeSniffer
PHP CodeSniffer is a utility to detect code style errors in PHP code. We use composer as a wrapper to manage the CodeSniffer version, dependencies, and execution.
First, fetch the development dependencies by running
For most MediaWiki extensions, skins and PHP libraries, executing
composer test will also execute CodeSniffer. Due to the large size of MediaWiki core, it is exposed as a separate command,
composer phpcs. If you run into issues with composer timing out, you can run it directly with
It is recommended that you pin a specific version in your
composer.json file. We try to adhere to the spirit of semver.org, but not the actual standard. The main thing we are concerned about is ensuring that no matter what, if when you run
composer test, it will pass if it previously passed, and not randomly fail because a new version was released. The build randomly failing is pain when you're trying to backport a patch or just trying to develop something and need to interrupt your work to fix it.
We are currently using 0 as our major version, and will bump the minor version for new sniffs, and bump the patch version for bug fixes or enhancements to existing sniffs. No stability is guaranteed for the actual PHP code included.
- Manual:Coding conventions/PHP
- Extension:BoilerPlate is a skeleton extension, its composer test Continuous integration entry point runs PHP CodeSniffer
- mediawiki-codesniffer (PHCS standard)
- Continuous integration/Entry points#PHP
- How to install - Instructions on how to install CodeSniffer for an extension