Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Mediawiki Codesniffer Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

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.

Gotchas and Tips

  • Version alignment is critical: The package version must match your target MediaWiki core (e.g., v48 for MW 1.42+); mismatched versions cause rule drift or missing checks. Always consult HISTORY.md.
  • Bootstrap file is mandatory: Omitting bootstrap-ci.php breaks path resolution and sniffs like FullQualifiedClassName, leading to false negatives or crashes.
  • Global variables trip people up: Sniffs like ExtendClassUsage and ValidGlobalName assume strict $wg.../wf... prefixes. If your project uses alternate globals (e.g., $piwikConfig), explicitly add them to ignoreList[].
  • Trailing commas are opt-in: The 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.
  • PHP 8.2+ requirement: This package dropped support for PHP <8.2. Ensure your local/dev/CI environment meets this—older systems will fail composer update.
  • No auto-detection for project globals: PHPCS won’t guess your project’s globals (e.g., $wgMyExtSetting). Configure ValidGlobalName::ignoreList[] and allowedPrefixes[] manually to avoid constant false positives.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport