NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist, #1012 most downloaded on Packagist
Mago is a toolchain for PHP that aims to provide a set of tools to help developers write better code.
Latest stable
1.60.2
Last release 6 days ago
16 Nov 2026
Ships fairly regularly
a new release about every 2 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
2 years old
199 releases · first in 2025
Drag across the ruler to compare, or tap a release to open it.
This is a small bug-fix release that addresses an issue discovered shortly after the first beta.
1.0.0-beta.2 Release NotesThis is a small bug-fix release that addresses an issue discovered shortly after the first beta.
mago init Generates Correct Configuration: The mago init command was generating a mago.toml file with outdated snake_case keys (e.g., print_width). This has been corrected, and the command now generates the proper kebab-case keys (e.g., print-width), ensuring that newly initialized projects work correctly without any manual file editing.Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-beta.1...1.0.0-beta.2
Welcome to the first beta release of Mago! This is a massive leap forward from the alpha series, bringing transformative performance improvements, a m
1.0.0-beta.1 Release Notes 🎉Welcome to the first beta release of Mago! This is a massive leap forward from the alpha series, bringing transformative performance improvements, a more robust and opinionated formatter, a smarter linter, brand new documentation, and countless bug fixes.
Mago is now faster, more stable, and easier to use than ever before.
This release introduces foundational changes that make Mago one of the fastest PHP toolchains available.
Atom implementation, providing lock-free, thread-safe, and globally unique strings for symbols. This is a key factor in the analyzer's performance improvements.mago-prelude Crate: PHP's built-in function and class stubs are now pre-compiled into a new mago-prelude crate. This enables full stub support in the Playground (WASM) for the first time and speeds up initialization.TUnion type in the analyzer now uses Cow (Clone-on-Write) to eliminate millions of heap allocations for common types like int and string, further reducing memory usage and CPU cycles.The formatter has received significant updates focused on stability, correctness, and a stronger, more consistent style.
--check Flag: A --check flag has been added to the format command. It exits with a non-zero code if any files need formatting, making it perfect for CI validation.The linter has been completely rewritten from scratch for the beta release. Now a pure, blazing-fast AST-walker, it's smarter, more flexible, and 2-3x faster than the alpha version. Key enhancements include:
--pedantic Flag: A new --pedantic flag allows you to run every single rule the linter knows about, overriding your configuration and PHP version constraints for the most exhaustive analysis possible.prefer-first-class-callable: Automatically fixes closures that can be converted to the modern ... syntax.use-compound-assignment: Recommends using operators like += and .=.no-redundant-nullsafe: Correctly identifies redundant ?-> operators (moved from the analyzer for better accuracy).The analyzer now has a clearer separation of concerns and has offloaded some responsibilities to the faster linter.
+ operator combines arrays has been fixed.The command-line interface and supporting tools have been improved for a better developer experience.
@mago-expect, @mago-ignore) now must be categorized (e.g., @mago-expect analysis:some-issue), making them clearer and more robust.code-count Reporter: A new reporting format that groups issues by code and sorts them by frequency, helping you identify the most common problems in your codebase.--semantics-only has been renamed to --semantics, and the internal --json-docs flag is now a public --json flag.kebab-case: To improve consistency, all keys in mago.toml must now be in kebab-case. For example, print_width is now print-width.lint: or analysis: (e.g., @mago-expect lint:no-empty).This beta release would not have been possible without the incredible support from the community. A huge thank you to everyone who has contributed their time and resources. Whether it is a pull request, a detailed issue report, or a $5 donation, your contributions keep the project moving forward and make Mago better for everyone!
A special thanks to:
In addition to building Mago, we now offer consulting services. If you need expert help to modernize, refactor, or rescue a complex PHP project, get in touch with us at contact@carthage.software.
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Mago v1.0.0-alpha.12 is here, with a major focus on giving you powerful new ways to configure the analyzer! This release introduces issue categories a
Mago v1.0.0-alpha.12 is here, with a major focus on giving you powerful new ways to configure the analyzer! This release introduces issue categories and project-wide issue ignoring, making it easier than ever to tailor the analysis to your needs and gradually adopt Mago on any codebase. We've also completely overhauled the mago init experience to get you started faster.
This release introduces two powerful new ways to control the issues Mago reports.
All analyzer diagnostics have been grouped into logical categories. This allows you to disable entire groups of checks in your mago.toml to reduce noise, which is perfect for gradual adoption.
All categories are enabled by default. To disable one, for example:
[analyzer]
# Suppress all issues related to null values.
nullable_issues = false
<details> <summary>The full list of available categories</summary>
ambiguity_issuesargument_issuesarray_issuesdeprecation_issuesexistence_issuesfalsable_issuesgenerator_issuesimpossibility_issuesiterator_issuesmethod_issuesmixed_issuesnullable_issuesoperand_issuesproperty_issuesredundancy_issuesreference_issuesreturn_issuestemplate_issuesunreachable_issues
</details>You can now create a project-wide baseline of ignored issues using the analyze.ignore configuration option. This is a great alternative to cluttering your code with numerous @mago-expect pragmas.
[analyzer]
ignore = ["mixed-argument", "unhandled-thrown-type"]
The mago init command now generates a comprehensive configuration file with all available analyzer settings commented out and explained. This makes every option easily discoverable without needing to consult external documentation.
The keys in mago.toml have been standardized to [formatter], [linter], and [analyzer] for consistency. To ensure backward compatibility, aliases for the old keys ([format], [lint]) and common variations ([analyser], [analyze], [analyse]) have been added, so existing configuration files will continue to work without modification.
@return string. A description), improving compatibility with WordPress-style docblocks.?>) could be formatted incorrectly, leading to non-idempotent results. (#299)Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.11...1.0.0-alpha.12
This release marks a massive step forward in the power and stability of the Mago analyzer. We're thrilled to introduce a completely rewritten `match`
This release marks a massive step forward in the power and stability of the Mago analyzer. We're thrilled to introduce a completely rewritten match expression analyzer and a new, optional check for unhandled exceptions.
As a sign of our growing confidence in the tool's stability, the large "EXPERIMENTAL" warning has been removed from the analyze command. This release also includes significant refactoring and polish for both the analyzer and the formatter.
match AnalyzerThe match expression analyzer has been completely rewritten from the ground up to resolve numerous bugs and correctness issues. The new implementation correctly simulates match semantics by sequentially analyzing each arm and narrowing the subject's type, providing far more accurate and useful diagnostics.
Key capabilities include:
match expression's resultA new, powerful check for unhandled exceptions has been added. This is an opt-in feature, disabled by default, which can be enabled with the check_throws = true config setting or the --check-throws=true CLI flag. When active, it will report an unhandled-thrown-type error if a function or method can throw an exception that is neither caught nor documented in a @throws tag.
@mago-expect comments now apply to any issue that contains them (in addition to issues they contain).if, switch, try, etc.) has been centralized, and a large amount of dead code has been removed from the analyzer's core, improving maintainability.use statements, comments around the closing parenthesis of function calls, and parenthesis handling for unary operators.This release closes the following issues:
Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.10...1.0.0-alpha.11
This is a landmark release! 🎉 We are thrilled to introduce comprehensive support for by-reference analysis, a major step forward in Mago's ability to
This is a landmark release! 🎉 We are thrilled to introduce comprehensive support for by-reference analysis, a major step forward in Mago's ability to understand complex PHP code. Alongside this huge new feature, this release continues our focus on polishing the formatter and improving the accuracy of the type system.
Mago now understands by-reference semantics! This is a foundational feature that replaces previous "unsupported operation" warnings with deep, accurate static analysis.
$a = &$b), passing arguments to by-reference parameters, returning by-reference, foreach loops (foreach ($arr as &$value)), and use (&$var) in closures.global, static, a by-ref parameter, or was passed as an argument to a method).if/else branches has been completely rewritten to accurately handle by-reference variables in conditional scopes.We've continued to refine the formatter for more stable and predictable output.
) of function calls and between if/else blocks separated by blank lines. The formatter is now more robust and idempotent.\t) as insignificant whitespace, preventing them from causing incorrect layout decisions around trailing comments.@psalm-* then @phpstan-* over generic @var and @return tags to ensure the most specific type is always used.mago analyze on our own Composer plugin in CI! This has already helped us find and fix a bug in template type inference related to empty arrays.imagick extension, improving analysis for projects that use it. Thanks, @Bleksak!This release closes the following issues:
Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.9...1.0.0-alpha.10
This release is all about polish! ✨ We've focused heavily on stabilizing and refining the code formatter, squashing a host of community-reported bugs
This release is all about polish! ✨ We've focused heavily on stabilizing and refining the code formatter, squashing a host of community-reported bugs to make the output cleaner, more predictable, and more aesthetically pleasing.
A big thank you to everyone who contributed by reporting issues!
This release introduces a significant number of improvements to the code formatter, targeting consistency, comment handling, and smarter line breaking.
Smarter Parentheses: The logic for adding parentheses has been completely overhauled. The formatter now uses a more robust, precedence-based system instead of a complex set of specific rules. This change eliminates many unnecessary parentheses that were previously added around binary, ternary, and unary cast expressions, leading to cleaner, more minimal code.
Improved Argument Lists & Comments: Formatting for function calls, especially those containing comments or nested calls, is now much more reliable. We've fixed issues with "dangling" comments (e.g., those between a ( and the first argument) and improved the inlining logic to prevent ugly, deeply-indented code for nested function calls.
Consistent Line Breaking: Several bugs that caused inconsistent or awkward line breaks have been fixed. Binary expressions used as values in assignments (e.g., 'key' => $a ?: match{...}) and multi-line logical expressions with comments are now formatted correctly and predictably.
Idempotency Fixes: Formatting the same file multiple times is now more stable. We've resolved issues with inconsistent spacing before closing tags (?>) and incorrect formatting of comments between if/else blocks to ensure the output is the same every time.
Beyond the formatter, this release also includes fixes for the type system and internal refactoring for better maintainability.
Type Syntax:
@param -1|string $a) are now parsed correctly.Analyzer Internal Refactoring:
This release closes the following issues:
Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.8...1.0.0-alpha.9
This release is packed with major improvements to the static analyzer, significantly boosting its accuracy and intelligence. We've fixed a whole class
This release is packed with major improvements to the static analyzer, significantly boosting its accuracy and intelligence. We've fixed a whole class of tricky type resolution bugs and introduced a powerful new feature for inferring closure parameter types. We also fixed a critical bug that had disabled all linter rules in the previous version.
array_map). It can now infer the precise type of a closure's parameters from the call site, eliminating a wide range of false positive errors that occurred within closures. ( Closes #281 )This release focuses heavily on correctness, with numerous fixes to the linter and analyzer.
override-attribute Rule: The override rule has been corrected to ignore methods inside traits, preventing false positives.@psalm-assert tags. Assertions with union types (e.g., int|string) and derived types (e.g., value-of<T>) are now handled correctly.readonly Property Writes: The analyzer's rules for readonly properties have been aligned with the PHP engine. A public readonly property is now correctly treated as having protected(set) visibility, and writing to it outside of a constructor is now correctly flagged as an error.@require Annotations: Fixed a bug where @require-implements and @require-extends annotations were not being checked when inherited from parent classes or traits.?, :) or match arm arrows (=>) were being misplaced during formatting. (Closes #280)@immutable, @mutation-free, and related annotations has been temporarily removed. The previous implementation was not robust enough, and we plan to re-introduce these features with a more thorough design after the stable release.mago fix in the documentation. (Thanks, @sasezaki! 🎉)Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.7...1.0.0-alpha.8
This release introduces a major architectural refactoring, replacing the tokio asynchronous runtime with a CPU-bound parallelism model powered by rayo
This release introduces a major architectural refactoring, replacing the tokio asynchronous runtime with a CPU-bound parallelism model powered by rayon. This change simplifies the entire concurrency model, improves robustness, and makes the application significantly more efficient for its core analysis tasks.
The new rayon-based pipeline has resulted in significant optimizations. Benchmarks comparing this release with the previous version show substantial speedups on small-to-medium projects and dramatic memory reductions on large codebases.
| Command | Metric | Before | After | Improvement |
|---|---|---|---|---|
mago analyze |
Speed | 152.0 ms | 110.2 ms | +38% Faster |
| Memory (RSS) | 156.52 MB | 127.69 MB | -18.4% Memory | |
| Memory (Peak) | 146.49 MB | 117.16 MB | -20.0% Memory | |
mago format |
Speed | 32.7 ms | 30.1 ms | +8.6% Faster |
| Memory (RSS) | 44.05 MB | 38.39 MB | -12.8% Memory | |
| Memory (Peak) | 40.85 MB | 35.00 MB | -14.3% Memory | |
mago lint |
Speed | 106.8 ms | 86.8 ms | +23.0% Faster |
| Memory (RSS) | 126.31 MB | 126.69 MB | ~ Neutral | |
| Memory (Peak) | 118.63 MB | 119.78 MB | ~ Neutral | |
mago lint -c |
Speed | 87.0 ms | 86.3 ms | ~ Neutral |
| Memory (RSS) | 122.77 MB | 124.67 MB | ~ Neutral | |
| Memory (Peak) | 115.91 MB | 117.60 MB | ~ Neutral | |
mago lint -s |
Speed | 25.5 ms | 24.5 ms | +4.1% Faster |
| Memory (RSS) | 34.86 MB | 29.11 MB | -16.5% Memory | |
| Memory (Peak) | 31.57 MB | 25.64 MB | -18.8% Memory |
| Command | Metric | Before | After | Improvement |
|---|---|---|---|---|
mago analyze |
Speed | 6.511 s | 6.489 s | ~ Neutral |
| Memory (RSS) | 1709.19 MB | 1375.25 MB | -19.5% Memory | |
| Memory (Peak) | 1503.40 MB | 1168.82 MB | -22.2% Memory | |
mago format |
Speed | 2.049 s | 2.068 s | ~ Neutral |
| Memory (RSS) | 306.52 MB | 293.14 MB | -4.4% Memory | |
| Memory (Peak) | 218.21 MB | 219.52 MB | ~ Neutral | |
mago lint -s |
Speed | 322.6 ms | 324.9 ms | ~ Neutral |
| Memory (RSS) | 208.25 MB | 192.06 MB | -7.8% Memory | |
| Memory (Peak) | 200.22 MB | 186.08 MB | -7.1% Memory |
The most significant change in this version is the complete removal of the tokio runtime. While tokio is excellent for I/O-bound tasks, Mago's workload (parsing, type inference, linting) is fundamentally CPU-bound. The switch to rayon's data-parallel model is better suited for this and has several key benefits:
async/await logic and manual task management have been replaced with a cleaner, more direct parallel iterator pattern. All command execute functions are now synchronous.pipeline Abstraction: The core logic for the analyze, lint, and format commands has been extracted into a new, reusable pipeline module. This provides two distinct orchestrators for different needs:
ParallelPipeline for complex, multi-phase tasks that require a global CodebaseMetadata.StatelessParallelPipeline for simple, single-phase tasks like formatting.starts_with to exclude all nested paths.Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.6...1.0.0-alpha.7
This is a major performance-focused release, delivering significant improvements to both execution speed and memory usage. Through a series of targete
This is a major performance-focused release, delivering significant improvements to both execution speed and memory usage. Through a series of targeted optimizations, Mago is now substantially faster on small-to-medium codebases and drastically leaner on large ones.
This release cycle has been dedicated to making Mago faster and more efficient. Benchmarks comparing this release (1.0.0-alpha.6) with 1.0.0-alpha.4 show the following results ( mago analyze ):
| Project | Metric | 1.0.0-alpha.4 |
1.0.0-alpha.6 |
Improvement |
|---|---|---|---|---|
| PSL (Small) | Speed | 143.2 ms | 118.6 ms | ~21% Faster |
| Memory | 174.80 MB | 154.67 MB | -11.5% Memory | |
| WordPress (Large) | Speed | 7.016 s | 6.692 s | ~5% Faster |
| Memory | 2065.36 MB | 1855.00 MB | -10.2% Memory |
On the large WordPress codebase, these changes resulted in over 210 MB of RAM savings, making the analyzer more capable of handling massive projects.
Key optimizations include:
Span Size Reduction: The core Span struct was reduced in size by 50% (from 32 to 16 bytes), dramatically lowering memory usage.rayon to discover and read files in parallel, providing a significant speedup on small projects.codex and algebra crates were migrated from BTreeMap to IndexMap for faster lookups.Cow and Arc: The database was refactored to use Copy-on-Write strings and Arc to share file data cheaply across threads.1.0.0-alpha.5 release.DateInterval class stub for more accurate analysis. (by @Bleksak in #273)list and keyed arrays.README.md file. (by @szepeviktor in #278)rand dependency has been removed from the mago-algebra crate.#[repr(C)] attributes were removed from AST and span structs.README.Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.4...1.0.0-alpha.6
This release introduces a major architectural overhaul with the new mago-database crate, significantly improving performance and laying a better found
This release introduces a major architectural overhaul with the new mago-database crate, significantly improving performance and laying a better foundation for future development. The type analyzer also receives substantial improvements, fixing several key bugs related to generic and loop variable inference.
mago-source crate has been completely replaced by the new mago-database crate. This is a significant architectural improvement that provides a cleaner, more performant, and thread-safe foundation for file management. It introduces a clear distinction between a mutable Database for building the file set and an immutable, cheap-to-clone ReadDatabase for high-speed concurrent analysis.This release includes numerous fixes to the type analyzer and formatter, improving accuracy and correctness.
break) were not correctly propagated to the parent scope. This resolves many false positive "dead code" and "redundant condition" errors. (Closes #264)static<...> Generics: The analyzer now correctly respects generic type parameters in @return static<T, U> docblocks. This fixes incorrect type inference in methods that transform a collection's generic types, like map. (Closes #266)possibly_undefined state is now correctly propagated through nested array access (e.g., $arr[$key1][$key2]). This eliminates false positive "redundant null coalesce" (??) errors. (Closes #267)::class on Generic object: Correctly infers the type of $variable::class as class-string when $variable is a generic object, instead of incorrectly resolving to mixed. (Closes #271)endif ?>). The logic for removing trailing ?> has also been corrected to avoid removing it when required. (Closes #272)count() Stub: The return type for the built-in count() function has been refined to be more precise for empty vs. non-empty arrays. (Closes #269)any type has been removed in favor of mixed to reduce confusion and align with standard PHP behavior.A special thank you to the following community members for their detailed bug reports, which were invaluable for this release:
Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.3...1.0.0-alpha.4
This is a significant alpha release that introduces major improvements to the type analyzer's accuracy, especially around conditional type narrowing.
Hello everyone,
This is a significant alpha release that introduces major improvements to the type analyzer's accuracy, especially around conditional type narrowing. We've also added a new linter rule and a debugging feature for better developer experience.
best-practices/no-short-opening-tag
A new rule has been added to discourage the use of short open tags (<?). While valid, this tag's availability depends on the short_open_tag setting in php.ini. This rule encourages using the full <?php tag for better portability and security.@psalm-trace: For easier debugging and compatibility, the analyzer now supports the @psalm-trace docblock tag. When encountered, it will report the inferred type of the specified variable at that point in the code.isset Refinement Fix
The analyzer now correctly refines the types of object properties after isset checks, especially in complex || conditions. This fixes a major bug where the analyzer would fail to determine that a property was non-null after a guard clause, leading to many false positives. (closes #253)if (is_bool($data['x'])), the type of $data is now correctly narrowed from array{'x': mixed} to array{'x': bool}. (closes #256)@template tag parser has been fixed to correctly handle constraint types that contain spaces, such as generics (Collection<string, int>) and shape arrays (array{name: string}). (closes #262);), ensuring correct spacing and newline placement around consecutive or trailing semicolons. (closes #263)<?)
Removed the incorrect semantic error for short open tags. This tag is valid in modern PHP, and the check has been moved to the new, optional linter rule.@var Assignment
Fixed an issue where @var types were not being applied correctly in some assignment contexts. (closes #261)This release significantly enhances the analyzer's ability to understand complex conditional logic. Thank you for your contributions and bug reports!
Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.2...1.0.0-alpha.3
Just a few hours after our first alpha, we're back with another release packed with new features, important bug fixes, and a ton of polish based on ea
Just a few hours after our first alpha, we're back with another release packed with new features, important bug fixes, and a ton of polish based on early feedback.
This release significantly enhances the analyzer's intelligence, particularly around inheritance and unused code detection.
The analyzer is now much smarter about how it handles traits. Previously a todo comment, we now have a full suite of checks for use statements, including:
@mutation-free or @external-mutation-free trait in a mutable class will now be flagged as an error.#[NoDiscard] AttributeLooking ahead, Mago now understands and respects the new #[NoDiscard] attribute proposed for PHP 8.5. If you discard the return value of a function or method marked with this attribute, Mago will report an error, helping you write more robust and future-proof code.
We've improved the stubs for several standard PHP functions, leading to more accurate type inference in your projects:
array_sum: Now correctly returns int if the input is an array<int>, and float otherwise (by @azjezz, closes #257).in_array: The signature has been corrected to use the array's value type (V) for the $needle parameter, not the key type (by @azjezz, closes #259).array_map: The return type now correctly preserves list type when appropriate (by @Nadyita in #254).array_reverse: A typo in the conditional return type has been fixed (by @azjezz, closes #255).The unused-statement check is now more intelligent and produces fewer false positives:
@must-use Fixed: The @must-use docblock tag is now parsed correctly.@pure functions as useless if they have by-reference parameters, as they can produce side effects (by @azjezz, closes #258)We've overhauled the error messages for all inheritance-related checks (extends, implements, and use). The new messages are clearer, more consistent, and provide more context to help you fix issues faster.
Full Changelog: https://github.com/carthage-software/mago/compare/1.0.0-alpha.1...1.0.0-alpha.2
This release marks a major milestone for Mago, introducing the highly anticipated static analyzer. We've been working hard to bring you a powerful new
<center> <img width="548" height="200" alt="image" src="https://github.com/carthage-software/mago/blob/main/assets/banner.svg" /> </center>
This release marks a major milestone for Mago, introducing the highly anticipated static analyzer. We've been working hard to bring you a powerful new tool to help you write better PHP code. This is the first alpha release of the 1.0.0 series, and we're excited to get it into your hands.
mago analyze is Here!The biggest new feature in this release is the mago analyze command. This is a brand new, built-in static analyzer for PHP, designed to find bugs and improve code quality. It's fast, powerful, and easy to use.
⚠️ Experimental Feature Warning The new
mago analyzecommand is highly experimental. It is a work in progress and you should expect it to have many false positives, potential panics, and other unexpected behavior. Please use it with caution and report any issues you find to our issue tracker.
We ran some initial benchmarks comparing the new analyzer against other popular PHP static analysis tools. These tests were performed on an M1 Macbook Pro, analyzing the entire wordpress-develop codebase.
<img width="1580" height="484" alt="hhgcq-mago-vs-psalm-vs-phpstan(1)" src="https://github.com/user-attachments/assets/f9df6343-4267-4f80-bc71-415acb619c65" />
While Mago is the fastest of all, we are still not happy with the performance and are hoping to improve it further in the future. Our goal is to make static analysis feel instantaneous.
<img width="2152" height="482" alt="zFdMQ--span-mago-vs-psalm-vs-phpstan-span-" src="https://github.com/user-attachments/assets/9ca42c2c-3321-45a1-8bfd-30157298a5bd" />
Memory usage is currently a problem, and Mago does use a lot of memory compared to other tools. We are actively working on fixing this issue by implementing more efficient data structures and codebase compilation techniques, and we hope to have more optimized releases soon.
With the introduction of the new mago analyze command, we now have two components that can emit issues: the linter and the analyzer. To distinguish which tool an @mago-expect or @mago-ignore comment is targeting, you must now specify a category.
@mago-expect best-practices/no-unused-parameter@mago-expect lint:best-practices/no-unused-parameterThe available categories are:
We understand that you might have many of these comments in your codebase. To make this transition painless, we've created a dedicated linter rule that will automatically add the lint: category to all your existing, uncategorized pragmas.
To run the fixer, execute the following command:
mago lint --no-default-plugins --plugins comments --fix
To preview the changes first, add the --dry-run flag.
While the analyzer was the main focus, we also squashed some important bugs and made a ton of improvements across the board:
use statement prefixes.float.clone binary operations are correctly parenthesized.no-unused-parameter rule is now much smarter. It correctly understands conditional blocks (if, while, etc.) and will no longer flag parameters as unused if they are only reassigned in a branch.8.5 and has adopted a rolling version policy for future PHP releases.$XDG_CONFIG_HOME.ariadne error reporting format.This release introduces several new crates for the analyzer infrastructure and removes others.
New Crates:
mago-analyzermago-algebramago-codexmago-collectormago-semanticsRemoved Crates:
mago-projectmago-reflectionmago-typingmago-trinaryTo update to this new version, simply run:
mago self-update
Full Changelog: https://github.com/carthage-software/mago/compare/0.26.1...1.0.0-alpha.1
This release introduces a new linter rule for best practices and a powerful new formatting option to improve code organization, alongside several key
Hello everyone,
This release introduces a new linter rule for best practices and a powerful new formatting option to improve code organization, alongside several key fixes for the formatter.
New Linter Rule: best-practices/no-sprintf-concatenation: A new rule has been added to discourage string concatenation with sprintf() calls (e.g., sprintf(...) . 'string'). The linter will now suggest incorporating the concatenated parts directly into the sprintf format string for better performance and readability. (#139)
New Formatter Option: separate_class_like_members: The formatter now inserts a single blank line between different kinds of members inside a class, trait, interface, or enum by default. This visually groups constants, properties, enum cases, trait uses, and methods, making complex class-like structures much easier to read. This behavior can be disabled by setting separate_class_like_members = false in your mago.toml file. (#223)
$obj->foo->bar()) are formatted for better consistency and readability. (#218, #205)Thank you for your contributions and for helping us improve Mago!
Full Changelog: https://github.com/carthage-software/mago/compare/0.26.0...0.26.1
We're excited to release Mago v0.26.0. This version introduces a major new feature for configuration management, along with important fixes for the fo
Hello everyone!
We're excited to release Mago v0.26.0. This version introduces a major new feature for configuration management, along with important fixes for the formatter and internal upgrades to keep the project modern and stable.
$HOME/mago.toml. This allows you to set default behaviors and preferences across all your projects without needing a local mago.toml in every one. This feature was contributed by @JungoQuentin (#222 #200)Thank you for your continued support and contributions!
Full Changelog: https://github.com/carthage-software/mago/compare/0.25.0...0.26.0
We're excited to announce the release of Mago v0.25.0! This release focuses heavily on improving the user experience for our Linux users by addressing
Hello everyone,
We're excited to announce the release of Mago v0.25.0! This release focuses heavily on improving the user experience for our Linux users by addressing compatibility issues and streamlining our build process.
glibc, which could cause "GLIBC_2.38 not found" errors on stable Linux distributions that use older, well-supported glibc versions.
We now build all *-linux-gnu binaries against a glibc version of 2.17 (via the manylinux2014 base image). This ensures that Mago will work out-of-the-box on a much wider range of Linux systems, including older but still widely used enterprise distributions, without requiring users to upgrade their entire system or fall back to musl builds..deb) packages for our Tier 2 build targets. Debian packages will continue to be provided for all Tier 1 Linux targets (x86_64, i686, aarch64).mago-syntax crate. While these changes don't affect external APIs, they contribute to the overall stability and maintainability of the project as we continue to work on the type checker.Thank you for your valuable feedback which led to these improvements!
Full Changelog: https://github.com/carthage-software/mago/compare/0.24.5...0.25.0
This release brings a couple of important formatting fixes to improve correctness and code layout, along with a key documentation update.
Hello everyone,
This release brings a couple of important formatting fixes to improve correctness and code layout, along with a key documentation update.
__halt_compiler(). All content after this token will be preserved exactly as-is, with no modifications or added newlines, protecting any subsequent binary data. #214mago lint --fix command, replacing the old, removed mago fix command. #213Thanks for your continued support and for reporting these issues!
Full Changelog: https://github.com/carthage-software/mago/compare/0.24.4...0.24.5
We're pushing a small patch release, version 0.24.4, to address a minor display issue from the previous version.
Hello everyone,
We're pushing a small patch release, version 0.24.4, to address a minor display issue from the previous version.
mago --version will now correctly display 0.24.4.This release contains no other functional changes. Thanks for your understanding!
Full Changelog: https://github.com/carthage-software/mago/compare/0.24.3...0.24.4
We're pushing a small but important patch release, 0.24.3, to clean up some internal definitions.
Hello everyone,
We're pushing a small but important patch release, 0.24.3, to clean up some internal definitions.
Full Changelog: https://github.com/carthage-software/mago/compare/0.24.2...0.24.3
Hi everyone! We're rolling out Mago v0.24.2, a maintenance release focused on bringing you some valuable bug fixes, enhancements, and stability improv
Hi everyone! We're rolling out Mago v0.24.2, a maintenance release focused on bringing you some valuable bug fixes, enhancements, and stability improvements.
T[]): The type parser now correctly understands the T[] shorthand syntax for array<T>, improving compatibility with common php projects docblocks.Many of these updates were carefully picked from our internal development branch where we're making exciting progress on the new Mago Static Analyzer. It's still a work in progress and not yet public, but we wanted to bring these stability improvements to you now. Stay tuned for more updates!
Full Changelog: https://github.com/carthage-software/mago/compare/0.24.1...0.24.2
A quick patch release for you! Mago v0.24.1 is now available, specifically addressing a critical build issue that was affecting our WebAssembly users.
Mago 0.24.1 🩹
A quick patch release for you! Mago v0.24.1 is now available, specifically addressing a critical build issue that was affecting our WebAssembly users.
🛠️ Fixes
mago-wasm to the wasm32-unknown-unknown target. This fix involves disabling the wasm-opt optimization pass for the time being and enabling the compile-time-rng feature of the ahash crate to ensure broader compatibility. Users building for WebAssembly should now find the process smooth again!We recommend everyone who was encountering issues with WASM builds, or planning to use Mago in a WebAssembly environment, to update to this version.
Thanks for your patience and for reporting these issues!
Auto-fix for Strict Behavior Rule 🛠️: The strictness/require-strict-behavior rule now supports auto-fixing, making it even easier to enforce strict ty
strictness/require-strict-behavior rule now supports auto-fixing, making it even easier to enforce strict types in your projects! (closes #170)best-practices/literal-named-argument rule. It encourages using named arguments for literals (booleans, numbers, nulls) to drastically improve code readability at the call site. (closes #195)NoDiscard attribute, using closure creation in constant expressions, the void cast, and asymmetric visibility on static properties.array{string}), allowing for more precise type definitions. Also includes Display trait implementations for easier AST debugging.php-version Crate Updates 🗓️: The php-version utility crate now includes constants for PHP 8.5, along with our dynamic LATEST and NEXT PHP version constants to help you target specific PHP versions. (Friendly reminder: LATEST and NEXT values will change over time!)🛠️ Fixes & Enhancements
mago-formatter can now be compiled to the wasm32-unknown-unknown target! (Thanks @dsherret, #193)🧹 Other Notable Changes
Full Changelog: https://github.com/carthage-software/mago/compare/0.23.0...0.24.0
BREAKING CHANGE: This refactor includes significant changes to the public API of the affected crates. Users may need to adapt to the new crate structu…
This release brings significant internal refactoring and key enhancements, primarily focused on improving the architecture and capabilities of Mago's syntax processing and CLI functionality.
Key Changes:
Refactored Syntax Processing Crates (#179):
mago_syntax. This simplifies dependency management and reflects the common usage patterns of these components.mago_type_syntax, dedicated to parsing PHP docblock type strings. This provides a reusable component for tools needing to understand docblock types.mago_syntax_core, to hold common, low-level components shared between different lexing/parsing tasks, reducing code duplication.Improved Linter Rule:
strictness/require-strict-behavior rule now allows dynamic strictness, enabling more flexible control over strict behavior enforcement.Improved CLI --exclude Option Handling (#180):
--exclude CLI option and the source.excludes configuration setting now correctly handle relative paths../, it is replaced with the workspace directory, ensuring that exclusions work as expected when Mago is run from different locations within a project.We hope these changes improve the performance, reliability, and usability of Mago.
Full Changelog: https://github.com/carthage-software/mago/compare/0.22.2...0.23.0
This release introduces a new filtering option for the mago lint command and adds more flexibility to the strictness/require-strict-behavior rule.
This release introduces a new filtering option for the mago lint command and adds more flexibility to the strictness/require-strict-behavior rule.
--minimum-level option: The mago lint command now accepts a --minimum-level option. This allows you to filter linting results based on the severity level. You can specify info, help, warning, or error. If any issue with the specified or higher severity level is found, the command will exit with a non-zero code. This is useful for configuring CI pipelines to fail on warnings, for example (#174) by @Zuruuh.strictness/require-strict-behavior rule: Added the allow-loose-behavior option to this rule. When enabled, the rule allows explicitly disabling strict behavior in functions that support it by passing false as the $strict parameter. By default, the rule still enforces using strict behavior.We hope these changes improve your linting experience and provide you with more control over your code analysis workflow.
Full Changelog: https://github.com/carthage-software/mago/compare/0.22.1...0.22.2
This patch release addresses a critical bug in the formatter, ensuring correct handling of leading function-like comments.
This patch release addresses a critical bug in the formatter, ensuring correct handling of leading function-like comments.
We recommend updating to this version to ensure consistent and accurate formatting.
Full Changelog: https://github.com/carthage-software/mago/compare/0.22.0...0.22.1
This release brings a mix of new linter rules, formatter enhancements, and crucial bug fixes, improving both code quality analysis and formatting prec
This release brings a mix of new linter rules, formatter enhancements, and crucial bug fixes, improving both code quality analysis and formatting precision.
string-interpolation-braces Linter Rule 🧱 (#168):
inline_empty_control_braces (Default: false)inline_empty_closure_braces (Default: true)inline_empty_function_braces (Default: false)inline_empty_method_braces (Default: false)inline_empty_constructor_braces (Default: true)inline_empty_classlike_braces (Default: false)inline_empty_anonymous_class_braces (Default: true)require_strict_types Linter Rule 🛠️ (#147):
declare(strict_types=1); to PHP files, simplifying strict type enforcement.We hope you enjoy the improvements!
Full Changelog: https://github.com/carthage-software/mago/compare/0.21.0...0.22.0
Removed the deprecated fix command, directing users to use lint --fix instead.
We are excited to announce the release of 0.21.0, which includes several new features, bug fixes, and improvements to enhance your development experience.
--format (or --fmt) option to mago lint --fix. This feature automatically formats files after linting fixes are applied, streamlining your workflow.#) into double-slash (C-style) comments (//). This improves consistency and compatibility.fix command, directing users to use lint --fix instead.This release addresses issues #156, #162, #163, and #164, and provides a more seamless linting and formatting experience.
Full Changelog: https://github.com/carthage-software/mago/compare/0.20.4...0.21.0
We are releasing 0.20.4 to address a critical lexer bug related to invalid base number prefixes.
We are releasing 0.20.4 to address a critical lexer bug related to invalid base number prefixes.
Full Changelog: https://github.com/carthage-software/mago/compare/0.20.3...0.20.4
We are releasing v0.20.3 to address several formatting bugs and enhance array table support within the formatter.
We are releasing v0.20.3 to address several formatting bugs and enhance array table support within the formatter.
This release addresses issues #159, #160, and #161, improving the overall robustness and accuracy of the formatter.
Full Changelog: https://github.com/carthage-software/mago/compare/0.20.2...0.20.3
We are releasing 0.20.2 to address a critical idempotency issue in the formatter's handling of conditional expressions (ternary operators).
We are releasing 0.20.2 to address a critical idempotency issue in the formatter's handling of conditional expressions (ternary operators).
We recommend all users update to 0.20.2 to ensure idempotent formatting of conditional expressions.
Full Changelog: https://github.com/carthage-software/mago/compare/0.20.1...0.20.2
We are releasing 0.20.1 to address a critical bug in the formatter related to heredoc and nowdoc string handling.
We are releasing 0.20.1 to address a critical bug in the formatter related to heredoc and nowdoc string handling.
$a = <<<FOO
{$bar} Hello
FOO;
would incorrectly become:$a = <<<FOO
{$bar}Hello
FOO;
We recommend all users update to v0.20.1 to ensure correct formatting of heredoc and nowdoc strings.
Full Changelog: https://github.com/carthage-software/mago/compare/0.20.0...0.20.1
We are excited to announce the release of 0.20.0, which brings significant enhancements to the formatter, along with several bug fixes and improvement
We are excited to announce the release of 0.20.0, which brings significant enhancements to the formatter, along with several bug fixes and improvements to the linter and project functionalities.
best-practices/no-boolean-literal-comparison rule by default, addressing issue #129.Stringable interface.We encourage users to update to 0.20.0 to take advantage of these new features and improvements. Thank you for your continued support!
Full Changelog: https://github.com/carthage-software/mago/compare/0.19.5...0.20.0
Improved Array Formatting with Comments: Enhanced array formatting to automatically break arrays into multiple lines when comments are present between
Full Changelog: https://github.com/carthage-software/mago/compare/0.19.4...0.19.5
This patch release addresses several formatting bugs and improves the overall formatting logic.
This patch release addresses several formatting bugs and improves the overall formatting logic.
Declare, For, Foreach, While, and If statements with colon-delimited bodies. Also, HaltCompiler is now correctly handled.ClosingTag terminators to add a space before the tag.OpeningTag statements.LineSuffixBoundary in the printer, ensuring correct spacing and line breaks.These changes address and close the following issues: #150, #138, #149, #151.
Removed accidental debug println statement left in v0.19.2.
Full Changelog: https://github.com/carthage-software/mago/compare/0.19.2...0.19.3
This patch release addresses specific formatting inconsistencies, enhancing both the accuracy and readability of the output.
### Bug Fixes & Improvements:
This patch release addresses specific formatting inconsistencies, enhancing both the accuracy and readability of the output.
Full Changelog: https://github.com/carthage-software/mago/compare/0.19.1...0.19.2
This patch release addresses several formatting issues reported by our community, focusing on improving the accuracy and consistency of our formatter.
This patch release addresses several formatting issues reported by our community, focusing on improving the accuracy and consistency of our formatter.
preserve_breaking_member_access_chain setting is enabled. Also corrected formatting of method calls and call arguments within these chains.These fixes address and close the following bug reports: #134, #136, #137.
A big thank you to @innocenzi for reporting these issues and helping us improve the formatter! Your feedback is invaluable.
Full Changelog: https://github.com/carthage-software/mago/compare/0.19.0...0.19.1
This release delivers a mix of exciting new features and crucial bug fixes, ensuring a more robust and flexible formatting experience.
This release delivers a mix of exciting new features and crucial bug fixes, ensuring a more robust and flexible formatting experience.
preserve_breaking_conditional_expression option!We hope you enjoy the improvements!
Full Changelog: https://github.com/carthage-software/mago/compare/0.18.1...0.19.0
This is a patch release to address a critical build issue in 0.18.0.
This is a patch release to address a critical build issue in 0.18.0.
0.18.0 was missing the build artifact for x86_64-unknown-linux-gnu due to a CI workflow error. This release corrects the workflow and provides the missing build.0.18.0 and 0.18.1. This release solely addresses the build issue.Full Changelog: https://github.com/carthage-software/mago/compare/0.18.0...0.18.1
This release brings a plethora of improvements to both the formatter and linter, focusing on enhanced readability, flexibility, and robustness.
This release brings a plethora of improvements to both the formatter and linter, focusing on enhanced readability, flexibility, and robustness.
print_width, enhancing readability.{}), which remain on a single line.preserve_breaking_member_access_chainpreserve_breaking_argument_listpreserve_breaking_array_likepreserve_breaking_parameter_listpreserve_breaking_attribute_listcomposer.json Config Generation 📦:
mago init command, when generating configuration from composer.json, non-existent autoload paths are now automatically removed.self-update command.A huge thank you to @bendavies and @innocenzi for their invaluable contributions! Your bug reports, suggestions, and feedback have been instrumental in improving Mago. Community feedback is what keeps Mago improving!
Full Changelog: https://github.com/carthage-software/mago/compare/0.17.0...0.18.0
This release of Mago brings new linting rules for Laravel, more formatter options, and bug fixes!
This release of Mago brings new linting rules for Laravel, more formatter options, and bug fixes!
laravel/anonymous-migration: Encourages the use of anonymous classes for migrations.laravel/middleware-in-routes: Enforces applying middleware in routes files instead of controllers.laravel/view-array-parameter: Promotes passing data to views using the array parameter in the view() function.array_table_style_alignment: Enables or disables table-style alignment for arrays.always_break_named_arguments_list: Controls whether to always break named argument lists into multiple lines.always_break_attribute_named_argument_lists: Controls whether to always break named argument lists in attributes into multiple lines.parentheses_in_attribute: Controls whether to include parentheses in attributes when they contain no arguments.default arm in match expressions. (by @azjezz in #112)This release includes valuable additions and improvements for both the linter and formatter, making Mago an even more powerful tool for analyzing and styling your PHP code. Enjoy! 🎉
Full Changelog: https://github.com/carthage-software/mago/compare/0.16.0...0.17.0
This release of Mago focuses on refining the formatter and removing unused configuration options.
This release of Mago focuses on refining the formatter and removing unused configuration options.
keyword_case option: Keywords will now always be formatted in lowercase, adhering to standard conventions and simplifying the configuration. (by @azjezz in #108)blank_line_after_open_tag option: The formatter now intelligently determines when to add newlines after opening tags, eliminating the need for manual configuration. (by @azjezz in afa1b336ccf184543ec29c5cd39b1c5d0fc4a9d8)space_after_not_operator option: This option allows you to add a space between the ! operator and the following expression (e.g., ! $foo) for improved readability. (by @azjezz in #101)This release streamlines the formatter and improves its accuracy.
A big thank you to @innocenzi for all the suggestions and bug reports in #100 and #99 that helped make this release possible! 🙏
Enjoy! 🎉
Full Changelog: https://github.com/carthage-software/mago/compare/0.15.0...0.16.0
This release of Mago focuses on improving the developer experience (DX) with a new initialization command, enhanced configuration options, and bug fix
This release of Mago focuses on improving the developer experience (DX) with a new initialization command, enhanced configuration options, and bug fixes.
mago init command: Effortlessly set up Mago for your project with the new interactive mago init command! This command guides you through the essential configuration options, including source paths, external dependencies, PHP version, and framework plugins. It can even detect and use settings from your composer.json file. This makes getting started with Mago a breeze! ✨
Global options: We've added several new global options to give you more control over Mago's behavior:
--config: Specify the path to your mago.toml configuration file.--php-version: Override the PHP version used for parsing and analysis.--threads: Control the number of threads used for linting and formatting.--allow-unsupported-php-version: Allow the use of unsupported PHP versions (use with caution!).--workspace: Define the workspace directory for your project. This also influences where Mago looks for the configuration file.These options can be used with any Mago command and must be specified before the command (e.g., mago --workspace my-project lint).
mago-token crate where the precedence of [ was incorrectly set, causing issues with parsing certain expressions.This release makes Mago even more user-friendly and reliable. We hope you enjoy the new features and improvements!
Full Changelog: https://github.com/carthage-software/mago/compare/0.14.0...0.15.0
Stdin input support: You can now use mago fmt --stdin-input to format code provided via stdin and output the result to stdout. This enables seamless i
Stdin input support: You can now use mago fmt --stdin-input to format code provided via stdin and output the result to stdout. This enables seamless integration with various editors and tools, streamlining your workflow. Check out our updated docs for editor integration recipes with Zed and VS Code:
Improved comment handling: The formatter now handles comments inside and around call argument lists more effectively, ensuring that comments are preserved and formatted correctly.
## Linter Improvements 🔍
@mago-expect comments: Introducing @mago-expect comments as a recommended alternative to @mago-ignore comments. While @mago-ignore completely silences the linter, @mago-expect allows the linter to still scan the code and verify that the expected issue is present. This helps prevent unintended issues from being suppressed and promotes more reliable code analysis.comment/use-expect-instead-of-ignore rule: This new rule recommends using @mago-expect comments instead of @mago-ignore comments, guiding you towards better linting practices.This release makes Mago an even more powerful and versatile tool for PHP code styling and analysis. We hope you enjoy the new features and improvements! 🎉
Full Changelog: https://github.com/carthage-software/mago/compare/0.13.1...0.14.0
This is a quick hotfix release to address a regression in the mago_casing crate that was introduced in 0.13.0.
This is a quick hotfix release to address a regression in the mago_casing crate that was introduced in 0.13.0.
Full Changelog: https://github.com/carthage-software/mago/compare/0.13.0...0.13.1
Deprecated `fix` command: The fix command has been deprecated in favor of lint --fix, simplifying the CLI and reducing redundancy. (by @azjezz in `10d…
This release of Mago focuses on enhancing the formatter, improving the linter, and refining the CLI.
ff86425)method_chain_break_threshold option: This option is no longer needed due to other improvements in method chain formatting. (by @azjezz in 048fac1)1718a97)cc3dca5)fix command: The fix command has been deprecated in favor of lint --fix, simplifying the CLI and reducing redundancy. (by @azjezz in 10d2abb)8a94457)6ccd95d)b3143d4)d48547a)b8ebdbc)This release includes a wide range of improvements and bug fixes for both the formatter and linter, making Mago an even more powerful tool for PHP code styling and analysis. Enjoy! 🎉
Full Changelog: https://github.com/carthage-software/mago/compare/0.12.0...0.13.0
Fine-grained parentheses control: You can now fine-tune how Mago handles parentheses in your code with three new options:
parentheses_around_new_in_member_access: Decide whether to include parentheses around instantiation expressions followed by a member access operator (->). This option is disabled by default, aligning with the streamlined style introduced in PHP 8.4. (#89)parentheses_in_new_expression: Control whether to include parentheses in new expressions, even when no arguments are provided. Enabled by default for explicitness. (#89)parentheses_in_exit_and_die: Choose whether to include parentheses in exit and die constructs, making them resemble function calls. Enabled by default for consistency. (#89)space_before_enum_backing_type_hint_colon option lets you control whether a space is added before the colon in enum backing type hints (e.g., enum Foo: int). (#88)remove_trailing_close_tag option allows you to control whether the trailing ?> tag is removed from PHP files. (#87)format() function now requires a PHPVersion argument. This change is necessary to support the parentheses_around_new_in_member_access option, which has version-specific behavior. (#89)We hope you enjoy these improvements to the Mago formatter! 🎉
Full Changelog: https://github.com/carthage-software/mago/compare/0.11.1...0.12.0
Linter Method Lookup Fix Fixed an issue where the linter used original method casing (e.g., doThing() vs dothing()) to look up method information. Mag
Linter Method Lookup Fix
Fixed an issue where the linter used original method casing (e.g., doThing() vs dothing()) to look up method information. Mago now consistently uses lowercase names for method reflection, ensuring PHP's case-insensitive method handling is respected. This resolves cases where methods were skipped during analysis.
Composer Plugin Version Resolution by @NeoIsRecursive in https://github.com/carthage-software/mago/pull/82
Fixed a bug in the Mago Composer plugin that caused it to ignore version constraints in composer.json and always install the latest version. It now honors the specified version range as expected.
Enjoy the stability improvements! 🛠️
Full Changelog: https://github.com/carthage-software/mago/compare/0.11.0...0.11.1
New Linter Rules Added several best-practice and analysis rules to improve code quality:
New Linter Rules
Added several best-practice and analysis rules to improve code quality:
best-practices/no-else-clause: Discourages the use else clause in an if statement.best-practices/no-boolean-flag-parameter: Flags boolean parameters that reduce readability.best-practices/no-boolean-literal-comparison: Detects redundant boolean comparisons.best-practices/no-empty-catch-clause: Warns about empty catch blocks.best-practices/dont-catch-error: Warns against catching PHP's internal Error throwable.redundancy/redundant-file: Identifies empty or redundant files.redundancy/redundant-mathematical-operation: Finds unnecessary math operations.analysis/override-attribute: Enforces use of #[\Override] for overridden methods (with auto-fix support).maintainability/long-inheritance-chain: Warns against deep inheritance hierarchies.analysis/parameter-name: Flag parameter name change in overriden methods.Linter Enhancements
Parser & Reflection Fixes
Static Call Handling
CLI Fixes
mago fix command functionality.Serialization Cleanup
Removed serialization logic from interner and project crates.
Source Management
Stub source names now prefixed with @ for clearer identification.
Rust Edition Update
Migrated from Rust 2021 to Rust 2024 edition. Ensure your toolchain is compatible.
Minimum Supported Rust Version (MSRV)
Updated MSRV to 1.85.0. Older Rust versions are no longer supported.
Enjoy the updates! 🚀
Full Changelog: https://github.com/carthage-software/mago/compare/0.10.0...0.11.0
Compilation Check Mode Introducing the --compilation flag (mago lint -c), allowing a quick check for compilation errors only without running the full
Compilation Check Mode
Introducing the --compilation flag (mago lint -c), allowing a quick check for compilation errors only without running the full linter.
Expanded PHP Version Support
Experimental PHP Version Support
allow_unsupported_php_version configuration option enables running Mago with unsupported PHP versions (below 7.2 or above 8.4).Crate Merging & Cleanup
reflector and semantics into a single project crate.traverser and symbol-table crates (mago_traverser and mago_symbol_table on crates.io).Walker Refactoring
project crate.Source Management Performance Fixes
Linter Performance
mago lint.Semantic Analysis Optimization
mago lint -s.Enjoy the updates! 🚀
We are excited to announce the release of Mago version 0.9.1, which brings significant improvements and new features to both the formatter and linter.
We are excited to announce the release of Mago version 0.9.1, which brings significant improvements and new features to both the formatter and linter. This release focuses on enhancing user control, improving code formatting accuracy, and addressing community feedback.
@mago-ignore Comment SupportThis release introduces a highly requested feature: the @mago-ignore comment. You can now selectively disable specific linter rules for targeted sections of your code. This provides a flexible way to handle false positives, suppress warnings in specific scenarios, or temporarily bypass certain rules when necessary.
@mago-ignore {plugin}/{rule} {description}:
{plugin}/{rule}: Specifies the linter rule to be ignored (e.g., strictness/require-return-type).{description} (Optional): A brief explanation of why the rule is being ignored. While optional, providing a description is highly recommended for code clarity and maintainability./**
* @mago-ignore strictness/require-return-type
*/
function example()
{
// @mago-ignore analysis/undefined-function-or-method
$a = foo();
}
The linter will also intelligently report any @mago-ignore comments that are no longer needed, helping you maintain a clean and relevant set of ignore directives.
This feature was implemented by @azjezz in PR #71, fulfilling a request from @M-arcus in Issue #46.
Ignore comments have been a long-standing community request. This addition empowers users to tailor the linter's strictness to their specific project needs, allowing for more nuanced control over code analysis and improved workflow.
Mago 0.9.1 introduces a new excludes configuration option for the formatter within your mago.toml configuration file. This powerful feature enables you to define patterns for files, directories, or glob patterns that should be excluded from formatting operations.
[format]
excludes = ["**/src/**/*.generated.php"]
Files matching these patterns will be skipped during formatting, ensuring you can maintain control over specific files that should not be automatically formatted while still benefiting from linting and other analysis functionalities.
This feature was implemented in PR #72 by @azjezz, in response to a request from @bendavies in Issue #28.
This enhancement provides greater flexibility in managing your formatting process, allowing you to selectively format your codebase based on project requirements and preferences.
This release addresses and resolves several bugs within the formatter specifically related to the handling of trailing and dangling comments. These fixes improve the accuracy and reliability of Mago's code formatting, especially in scenarios with complex comment placements within code blocks and after opening tags.
These important fixes are implemented by @azjezz in PR #73.
This ensures that your code is formatted consistently and predictably, even with intricate comment structures, leading to a more polished and professional codebase.
Happy Formatting & Linting!
Full Changelog: https://github.com/carthage-software/mago/compare/0.9.0...0.9.1
…now detected ✅ Static method calls on traits (deprecated in PHP 8.2+) now trigger warnings ✅ Fix: Severity levels now correctly respect user configura…
Mago 0.9.0 introduces deeper undefined reference checks, a brand-new mago find command for locating symbol references, and a new rule to catch unnecessary hash comments (#️⃣).
Mago now detects more cases of undefined methods, functions, constants, and enum cases, preventing runtime errors before they happen.
✅ Calling an undefined, non-static, or abstract static method is now flagged
✅ Creating a closure for an undefined function is now reported
✅ Class-like constants & enum cases that are undefined are now detected
✅ Static method calls on traits (deprecated in PHP 8.2+) now trigger warnings
✅ Fix: Severity levels now correctly respect user configurations
🔎 Why This Matters: These changes ensure Mago catches more real-world issues in PHP codebases, helping developers avoid hard-to-debug runtime errors.
mago find 🔍A powerful new command has landed! mago find [query] lets you search for symbol references (e.g., functions, classes, traits, enum cases, and more) across your PHP project instantly.
mago find SomeClassmago find some_functionmago find SomeTrait🎯 Built for speed & accuracy, this feature is ideal for navigating large codebases, understanding dependencies, and future LSP integrations.
📸 Example screenshots:
<img width="1714" alt="Screenshot 2025-02-05 at 13 33 10" src="https://github.com/user-attachments/assets/fc2e159b-1c69-4245-a567-a58fbbd709a3" /> <img width="1176" alt="Screenshot 2025-02-05 at 13 34 36" src="https://github.com/user-attachments/assets/3fe5de50-55d6-4b05-90f2-47b12a8db8ca" />
Big internal refactoring:
✅ Improved performance in various crates
✅ The linter rule system is now more efficient & extendable
✅ These changes pave the way for future improvements
Full Changelog: https://github.com/carthage-software/mago/compare/0.8.1...0.9.0
Fixed incorrect version checks for null and false type hints:
null and false type hints:
null and false in union types for PHP 8.0+Thanks to @Nadyita for reporting #65
mago lint --reporting-format=gitlab
Thanks to @vvvinceocam for the contribution #62
Thank you for your feedback and contributions! 🚀
Full Changelog: https://github.com/carthage-software/mago/compare/0.8.0...0.8.1
The compatibility plugin has been removed as its functionality is now integrated into the core semantics analyzer.
compatibility Plugincompatibility plugin has been removed as its functionality is now integrated into the core semantics analyzer.Thank you for using Mago! 🚀
Full Changelog: https://github.com/carthage-software/mago/compare/0.7.0...0.8.0
> Note: This is a breaking change for WASM consumers – see docs for migration guidance.
This release delivers a complete rewrite of the mago_wasm crate to empower web-based PHP tooling:
Note: This is a breaking change for WASM consumers – see docs for migration guidance.
Fixed Non-Zero Exit Code for Warnings/Notes: In version 0.6.1, we fixed the exit code behavior to ensure mago lint exits with a non-zero code when err
0.6.1, we fixed the exit code behavior to ensure mago lint exits with a non-zero code when errors are present. However, this inadvertently caused the command to exit with a non-zero code even when only warnings, notes, or help messages were present. This has now been fixed.level <= Level::Error with the cleaner has_minimum_level(Level::Error) method, which correctly checks if any issues meet or exceed the error level.mago self-update
composer require carthage-software/mago:^0.6.1 --dev
cargo install mago@0.6.1
This fix is critical for users relying on mago lint in automated workflows, such as CI/CD pipelines, where a non-zero exit code is expected when linting errors are found. Without this fix, pipelines could incorrectly proceed despite linting failures, potentially allowing insecure or problematic code to be deployed.
We appreciate the community’s support in making Mago better. If you encounter any issues or have suggestions, please open an issue on GitHub.
Happy linting! 🚀
Fixed Exit Code Behavior: The mago lint command now correctly exits with a non-zero status code when linting errors are detected. Previously, it would
mago lint command now correctly exits with a non-zero status code when linting errors are detected. Previously, it would exit with a zero status code even when errors were present, which could mislead CI/CD pipelines or scripts into thinking the linting passed successfully.mago_reporting crate to ensure the get_highest_level method in IssueCollection correctly identifies the highest severity level. The issue stemmed from the reversed order of the Level enum fields, which has now been fixed. These tests prevent future regressions.mago self-update
composer require carthage-software/mago:^0.6.1 --dev
cargo install mago@0.6.1
This fix is critical for users relying on mago lint in automated workflows, such as CI/CD pipelines, where a non-zero exit code is expected when linting errors are found. Without this fix, pipelines could incorrectly proceed despite linting failures, potentially allowing insecure or problematic code to be deployed.
We appreciate the community’s support in making Mago better. If you encounter any issues or have suggestions, please open an issue on GitHub.
Happy linting! 🚀
Full Changelog: https://github.com/carthage-software/mago/compare/0.6.0...0.6.1
Mago now includes a security plugin, which detects potential security vulnerabilities in your PHP code.
Mago 0.6.0 introduces new compatibility rules, enhanced CLI flexibility, a new security plugin, and expanded functionality for the fix command.
We've added new compatibility rules to detect and warn about features introduced in PHP 8.2, 8.3, and 8.4, helping you ensure your code runs on the intended PHP version.
compatibility/dnf-type-hint-feature – Detects usage of Disjunctive Normal Form (DNF) type hints.compatibility/readonly-class-feature – Warns when using readonly classes before PHP 8.2.compatibility/trait-constants-feature – Detects constants inside traits, which are only available in PHP 8.2.compatibility/true-type-hint-feature – Ensures true as a type hint is used only in PHP 8.2+.compatibility/typed-class-constant-feature – Detects usage of typed class constants, available in PHP 8.3.compatibility/hooked-property-feature – Ensures hooked properties are only used in PHP 8.4+.compatibility/new-without-parentheses-feature – Detects new expressions without parentheses, available from PHP 8.4.👉 View details for each rule using:
mago lint --explain compatibility/readonly-class-feature
(Replace readonly-class-feature with any other rule name to learn more.)
--no-default-plugins & --pluginsWe've improved the lint and fix commands with new flags to fine-tune which plugins are enabled.
--no-default-plugins (-n): Disables default plugins, overriding linter.default_plugins in your config.--plugins (-p): Enables one or more specific plugins, overriding linter.plugins.👉 Examples:
compatibility plugin:mago lint -n -p compatibility
mago lint -n -p compatibility --list-rules
Mago now includes a security plugin, which detects potential security vulnerabilities in your PHP code.
mago lint -n -p security --list-rules
mago lint --explain security/<rule-name>
mago fix Now Accepts PathsThe mago fix command has been expanded to allow specifying paths, so you can apply fixes to a specific file or directory without affecting the entire project.
👉 Examples:
mago fix path/to/file.php
migration plugin in a specific directory:mago fix path/to/dir -n -p migration
Mago 0.6.0 gives you more control over linting and fixing, improves PHP compatibility checks, and introduces security rules to help safeguard your codebase.
Upgrade today and enjoy more power and flexibility in your PHP workflow! 🚀
Full Changelog: https://github.com/carthage-software/mago/compare/0.5.1...0.6.0
We sincerely apologize for the issues encountered in v0.5.0. This hotfix addresses critical regressions:
We sincerely apologize for the issues encountered in v0.5.0. This hotfix addresses critical regressions:
Bug Fixes:
Run linting on specific files/directories or file descriptors:
Run linting on specific files/directories or file descriptors:
# Lint single file
mago lint example.php
# Lint multiple files/directories
mago lint src/ tests/ example.php
# Lint via process substitution (Unix-like systems)
mago lint <(echo '<?php while(true) { break; }')
Added ignore_closure_types option to skip parameter/return type checks for:
For more information, use mago lint --explain strictness/require-parameter-type and mago lint --explain strictness/require-return-type
Critical Rule Fixes:
MAGO_LOG environment variableCompatibility Improvements:
Diagnostics & Logging:
Full Changelog: https://github.com/carthage-software/mago/compare/0.4.1...0.5.0
One column per month.