This is PHP Code Sniffer rule set based on the
wikimedia/mediawiki-tools-codesniffer
rules which encode the conventions for MediaWiki
projects.
- Allow longer line lengths. Lines longer than 120 chars will generate a
warning. Ignore line length in
tests/*
directory. - Allow unknown annotations.
- Do not check PHPUnit tests for
@covers
annotations - we're using PHP attributes which are not supported yet. See https://phabricator.wikimedia.org/T329048 We're enforcing the existence of coverage information with therequireCoversAnnotation
config setting of PHPUnit.
-
Require the library as a composer dependency:
composer require-dev wmde/fundraising-phpcs
-
Create a .phpcs.xml with the following minimal configuration:
<?xml version="1.0"?> <ruleset> <rule ref="./vendor/wmde/fundraising-phpcs/WMDE/Fundraising"/> <file>.</file> <arg name="extensions" value="php"/> <arg name="encoding" value="UTF-8"/> </ruleset>
The installation automatically installs the phpcs
(style checker) and
phpcbf
(style fixer) binaries into vendor/bin
. When your .phpcs.xml
file is in place, run the command
vendor/bin/phpcs
This repository should create a new major release whenever the MediaWiki coding standard has a new major release or you add a rule that will break existing code.
If you disable a rule, you can do a minor release.