mediawiki/mediawiki-codesniffer
PHP CodeSniffer ruleset that enforces MediaWiki coding conventions. Install via Composer, add the MediaWiki standard to your phpcs.xml, then run phpcs/phpcbf to lint and auto-fix issues. Includes configurable sniffs for project-specific needs.
Begin by installing the package as a dev dependency via Composer. Add "mediawiki/mediawiki-codesniffer" to require-dev, then create a .phpcs.xml configuration file referencing the bundled MediaWiki ruleset and including the required bootstrap file (utils/bootstrap-ci.php). Define Composer scripts (composer test and composer fix) to run PHPCS and PHPCBF. The first practical step is running composer test on your project—this will expose violations such as missing trailing commas in multi-line arrays, incorrect global variable prefixes ($wg...), or improperly indented use statements.
Developers integrate this into daily workflows primarily during local development and CI. Before committing, run composer fix to auto-correct trivial issues (e.g., whitespace, quote styles, array formatting). In IDEs like VS Code, enable PHP Sniffer or similar extensions to surface violations in real time. For MediaWiki extension development, this is non-negotiable—patches must pass these checks to be accepted upstream. Customize your .phpcs.xml to align with project needs: enable FullQualifiedClassName for modern PHP class usage, or extend ignoreList/allowedPrefixes for legacy project globals. In CI (e.g., GitHub Actions), run composer test as part of the linting job, using the same .phpcs.xml to ensure consistency between local and CI.
HISTORY.md.bootstrap-ci.php breaks path resolution and sniffs like FullQualifiedClassName, leading to false negatives or crashes.ExtendClassUsage and ValidGlobalName assume strict $wg.../wf... prefixes. If your project uses alternate globals (e.g., $piwikConfig), explicitly add them to ignoreList[].TrailingComma sniff defaults to disabled. Enable it early with <property name="multiLine" value="true" /> to reduce noisy Git diffs—but warn contributors it’s only for multi-line arrays by default.composer update.$wgMyExtSetting). Configure ValidGlobalName::ignoreList[] and allowedPrefixes[] manually to avoid constant false positives.How can I help you explore Laravel packages today?