Skip to content

Consider Mago as an all-in-one replacement for PHPCS, PHPStan and parallel-lint #433

Backlog

Description

@rajandangi

Feature Request

Describe your use case and the problem you are facing

wp-cli-tests runs four separate PHP tools: php-parallel-lint, PHPCS (WPCS and PHPCompatibility), PHPStan with several extensions, and a separate formatter where a project uses one. Each tool has its own config, version constraints and stubs. They are all Composer dev dependencies, so their constraints have to resolve together across every command repo.

Mago is a single Rust binary that formats, lints and runs static analysis. We use it on a WordPress theme (mago format --check, mago lint, mago analyze), and one config file replaces three tools there. It's also much faster than running PHPCS and PHPStan one after the other.

Is there any plan, or interest, in evaluating Mago for WP-CLI?

Describe the solution you'd like

Not a drop-in switch. A first step could be an optional composer mago script in wp-cli-tests, running next to the current checks, to compare their results on a few command repos. Mago is stable (1.61.0) and installs as a Composer dev dependency (carthage-software/mago), so it fits the current setup.

Drawbacks I can see:

  • Mago has no equivalent of WPCS's WordPress-specific sniffs (escaping, nonces, i18n) or of PHPCompatibility, so PHPCS would probably still be needed for those.
  • PHPStan baselines and extensions (phpstan-wordpress, phpstan-strict-rules) don't carry over, so switching analyzers means rebuilding baselines in each repo.
  • The carthage-software/mago Composer package requires PHP 8.1+, but wp-cli-tests supports PHP 7.2.24+. Mago would need to run only in a PHP 8.1+ lint job, or be installed outside Composer, rather than being a normal require-dev entry. Mago can still analyze code that targets older PHP versions.

Activity

  1. swissspidy commented on Nov 25, 2026

    @swissspidy
    Member

    Thanks for bringing this up.

    At the moment I don't really see a need to switch. The current toolchain works well for us and is fast enough. We also benefit from the ongoing PHPStan improvements in WordPress core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    maybelaterscope:testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions