{{ message }}
(Added) Mago static analysis and lint diagnostics#3052
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new optional LanguageServerMago integration to surface Mago diagnostics in Phpactor’s language server, paralleling the existing PHPStan/Psalm integrations.
Changes:
- Registers two new diagnostics providers:
mago(mago analyze) andmago-lint(mago lint), with separate enable flags. - Implements a process runner + JSON diagnostics parser that maps Mago byte offsets into LSP ranges and supports related information from secondary spans.
- Adds configuration suggestor, documentation, fixtures, and unit/smoke tests for the integration.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b494284 to
9bafa55
Compare
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
dantleech
reviewed
Jun 24, 2026
9bafa55 to
1bd2037
Compare
Surface diagnostics from the Mago toolchain (a Rust PHP linter, formatter and static analysis tool) in the language server, giving users a fast alternative to the existing PHPStan and Psalm integrations. Two providers are registered as an optional extension: "mago" runs "mago analyze" for static analysis and "mago-lint" runs "mago lint" for style and code smells. The current buffer is streamed to Mago on stdin so diagnostics update as you type, and the JSON report is mapped to LSP diagnostics with precise byte-offset ranges and related information for secondary spans. The extension is disabled by default. When enabled, analysis is on and the linter is opt-in. A suggestor offers to enable it when the carthage-software/mago Composer package is present. Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
1bd2037 to
558ff8c
Compare
dantleech
reviewed
Jun 25, 2026
| * Runs `mago <subcommand> --reporting-format=json --stdin-input <relative path>` | ||
| * with the document text piped on stdin, and parses the result. | ||
| * | ||
| * Mago is a native (Rust) binary, so the command is run directly without a PHP |
Collaborator
There was a problem hiding this comment.
hmm, isn't the wrapper in vendor/bin a PHP script?
Collaborator
|
looks good, thanks |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Phpactor already surfaces static analysis in the editor through PHPStan and Psalm, but offered no way to use Mago, the Rust PHP toolchain that runs considerably faster and understands the same PHPStan and Psalm annotations. A new optional LanguageServerMago extension closes that gap by registering two language server diagnostics providers that mirror the existing integrations: the mago provider runs
mago analyzefor static analysis, and the mago-lint provider runsmago lintfor style and code smells. The current buffer is streamed to Mago over standard input so results update as you type, and its JSON report is mapped to LSP diagnostics with precise byte-offset ranges and related information for secondary spans. The extension is disabled by default; once enabled, analysis is active immediately while the linter remains an explicit opt-in, and a configuration suggestor offers to switch it on when the carthage-software/mago Composer package is detected. Developers who enable it gain live Mago diagnostics in their editor alongside the existing PHPStan and Psalm output, with no change in behaviour for anyone who leaves it off.