This project implements a set of rules for use with PHP CodeSniffer.
See MediaWiki conventions on our wiki for a detailed description of the coding conventions that are validated by these rules. :-)
-
Create a composer.json which adds this project as a dependency:
{ "require-dev": { "mediawiki/mediawiki-codesniffer": "27.0.0" }, "scripts": { "test": [ "phpcs -p -s" ], "fix": "phpcbf" } }
-
Create a .phpcs.xml with our configuration:
<?xml version="1.0"?> <ruleset> <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/> <file>.</file> <arg name="bootstrap" value="./vendor/mediawiki/mediawiki-codesniffer/utils/bootstrap-ci.php"/> <arg name="extensions" value="php,php5,inc"/> <arg name="encoding" value="UTF-8"/> </ruleset>
-
Install:
composer update
-
Run:
composer test
-
Run:
composer fix
to auto-fix some of the errors, others might need manual intervention. -
Commit!
Note that for most MediaWiki projects, we'd also recommend adding a PHP linter
to your composer.json
– see the full documentation for more details.
- Migrate the old code-utils/check-vars.php