Skip to content
Github mirror of MediaWiki tool codesniffer - our actual code is hosted with Gerrit (please see https://www.mediawiki.org/wiki/Developer_access for contributing)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
MediaWiki
utils
.gitattributes
.gitignore
.gitreview
.phpcs.xml
COPYRIGHT
HISTORY.md
LICENSE
README.md
composer.json
phpunit.bootstrap.php
phpunit.xml.dist

README.md

MediaWiki coding conventions

Abstract

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. :-)

How to install

  1. Create a composer.json which adds this project as a dependency:

    {
    	"require-dev": {
    		"mediawiki/mediawiki-codesniffer": "25.0.0"
    	},
    	"scripts": {
    		"test": [
    			"phpcs -p -s"
    		],
    		"fix": "phpcbf"
    	}
    }
    
  2. 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>
    
  3. Install: composer update

  4. Run: composer test

  5. Run: composer fix to auto-fix some of the errors, others might need manual intervention.

  6. 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.

TODO

  • Migrate the old code-utils/check-vars.php

You can’t perform that action at this time.