Skip to content

Conversation

@kzndotsh
Copy link

@kzndotsh kzndotsh commented Nov 26, 2025

Add MediaWiki CodeSniffer to the project to enforce coding standards and provide a consistent workflow for linting and fixing PHP code.

The initial composer test run will report a large number of pre-existing whitespace and comment issues in configs/*.php and LocalSettings.php. These are not introduced by this PR and should be addressed in a separate, focused cleanup.


Open in Cursor Open in Web

Summary by Sourcery

Integrate PHP code quality tooling into the wiki project using MediaWiki CodeSniffer and Composer scripts.

New Features:

  • Add MediaWiki CodeSniffer as a dev dependency and configure it via a project-level .phpcs.xml ruleset.
  • Introduce Composer scripts for running code style checks and automatic fixes through phpcs and phpcbf.

Enhancements:

  • Document the PHP code quality workflow in the README, including installation and usage of composer test and composer fix.

Build:

  • Update composer.json to define dev requirements, code quality scripts, and plugin allowances for the PHP CodeSniffer installer.

@cursor
Copy link

cursor bot commented Nov 26, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 26, 2025

Reviewer's Guide

Adds MediaWiki CodeSniffer as a dev dependency, wires it into composer scripts for linting and autofixing PHP code, documents the workflow in the README, and configures PHPCS rules for the wiki PHP codebase.

Flow diagram for composer test and composer fix workflows

flowchart TD
    A["Start in wiki/ directory"] --> B{Command}

    B -->|composer test| C["Run composer script test"]
    B -->|composer fix| J["Run composer script fix"]

    %% composer test path
    C --> D["Invoke phpcs script (phpcs -ps)"]
    D --> E["phpcs loads .phpcs.xml ruleset"]
    E --> F["phpcs scans PHP files (excluding vendor and node_modules)"]
    F --> G{Coding standard violations?}
    G -->|No| H["Exit 0 (success)"]
    G -->|Yes| I["Exit non-zero, list violations in terminal"]

    %% composer fix path
    J --> K["Invoke phpcbf script (phpcbf)"]
    K --> L["phpcbf loads .phpcs.xml ruleset"]
    L --> M["phpcbf attempts to auto-fix PHP files"]
    M --> N["Auto-fix complete"]
    N --> O["(Optional) Developer re-runs composer test to verify clean state"]
Loading

File-Level Changes

Change Details Files
Introduce MediaWiki CodeSniffer as a development dependency and wire it into composer scripts for linting and fixing.
  • Add mediawiki/mediawiki-codesniffer as a require-dev dependency with a fixed version.
  • Define composer scripts for running phpcs, phpcbf, a test alias that invokes phpcs, and a fix alias that runs phpcbf.
  • Configure composer allow-plugins to enable dealerdirect/phpcodesniffer-composer-installer.
wiki/composer.json
wiki/composer.lock
Document the new PHP code quality workflow for contributors.
  • Add a Code quality section explaining how to install dependencies with composer inside wiki/.
  • Describe how to run composer test to execute MediaWiki CodeSniffer checks defined in .phpcs.xml.
  • Describe how to run composer fix to auto-fix sniffs via phpcbf.
README.md
Add PHPCS ruleset configuration for the wiki project.
  • Create a .phpcs.xml ruleset that imports the MediaWiki standard from the installed codesniffer package.
  • Configure PHPCS to scan all PHP files under wiki/, using the CI bootstrap, UTF-8 encoding, and only php extensions.
  • Exclude vendor and node_modules directories from scanning.
wiki/.phpcs.xml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Integrates PHP_CodeSniffer and MediaWiki coding standards for improved code quality.

Co-authored-by: admin <admin@kaizen.wtf>
@Atmois Atmois force-pushed the cursor/integrate-php-codesniffer-standards-gpt-5.1-codex-b0a1 branch from ae54c69 to 5f36795 Compare November 26, 2025 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants