Releases: carthage-software/mago
Mago 0.13.1
This is a quick hotfix release to address a regression in the mago_casing crate that was introduced in 0.13.0.
Bug Fixes 🐛
- Fixed incorrect casing for class names: In version 0.13.0, mago_casing was modified to support numbers within class names. However, this change inadvertently introduced a bug that allowed class names to start with a lowercase character. This has been corrected to ensure that class names are correctly cased according to the PSR-12 coding standard.
Build Fixes 🏗️
- Restored missing builds: Due to the regression in mago_casing, the 0.13.0 release was missing builds for macOS arm, Linux x86, Windows x86, and WASM. These builds have been restored in this release.
Full Changelog: 0.13.0...0.13.1
Mago 0.13.0
This release of Mago focuses on enhancing the formatter, improving the linter, and refining the CLI.
Formatter Enhancements 🛠️
- Fluent member access chains: The formatter now supports fluent member access chains, allowing for more concise and readable formatting of alternating property access and method calls. (by @azjezz in #90)
- Expanded member access chain handling: The formatter now handles both property accesses and method calls in member access chains, providing more consistent and comprehensive formatting. (by @azjezz in #91)
- Hugging single instantiation arguments: The formatter now "hugs" single instantiation arguments in function calls, resulting in more compact and readable code. (by @azjezz in #92)
- Expanding last instantiation argument: The formatter now expands the last instantiation argument in a function call if it has multiple named arguments, improving readability for complex expressions. (by @azjezz in #93)
- Enhanced member access chain printing conditions: Refined the conditions for printing member access chains to improve formatting consistency. (by @azjezz in
ff86425
) - Removed
method_chain_break_threshold
option: This option is no longer needed due to other improvements in method chain formatting. (by @azjezz in048fac1
) - Expanding first argument if it's an array: The formatter now expands the first argument in a function call if it's an array, improving readability for complex expressions. (by @azjezz in
1718a97
)
Linter Improvements 🔍
- New strictness rules: Added new rules to the strictness plugin to help prevent loose comparison and type juggling issues, promoting stricter and more predictable code. (by @vvvinceocam in #84)
- Panic on parse errors in tests: Improved the linter's test suite by panicking when a test case contains a parse error, ensuring that test cases are valid. (by @azjezz in
cc3dca5
)
CLI Refinements 🖥️
- Deprecated
fix
command: Thefix
command has been deprecated in favor oflint --fix
, simplifying the CLI and reducing redundancy. (by @azjezz in10d2abb
)
Other Changes
- Fixed parsing assignment expressions: Resolved an issue with parsing assignment expressions nested within binary expressions. (by @azjezz in
8a94457
) - Fixed formatting binaryish expressions: Improved the formatting of binary expressions to handle certain edge cases correctly. (by @azjezz in
6ccd95d
) - Fixed printing while loop condition: Corrected the printing of while loop conditions to ensure accurate formatting. (by @azjezz in
b3143d4
) - Fixed inlining parameter attributes: Resolved an issue with inlining parameter attributes in function definitions. (by @azjezz in
d48547a
) - Allowed mixed numeric-lowercase chars in class-name prefixes: Updated casing rules to allow mixed numeric and lowercase characters as part of a class name prefix. (by @azjezz in
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: 0.12.0...0.13.0
Mago 0.12.0
New Features 🆕
- 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 innew
expressions, even when no arguments are provided. Enabled by default for explicitness. (#89)parentheses_in_exit_and_die
: Choose whether to include parentheses inexit
anddie
constructs, making them resemble function calls. Enabled by default for consistency. (#89)
- Space control in enums: The
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) - Trailing close tag removal: The
remove_trailing_close_tag
option allows you to control whether the trailing?>
tag is removed from PHP files. (#87)
Formatting Enhancements 🪄
- Improved consistency: We've tackled inconsistencies in formatting various code constructs, including comments, arrays, assignments, binary expressions, and more! (#85)
- Better wrapping: Mago now handles edge cases in wrapping more effectively, ensuring consistent and predictable output. (#85)
- Enhanced width calculation: We've refined the width calculation logic to accurately measure the width of strings, leading to more precise formatting. (#85)
- Use statement organization: Gain more control over use statement formatting with options to sort, expand, and separate them. (#83)
Bug Fixes 🐛
- PHP in HTML alignment: Fixed an issue where indented PHP code within HTML was not aligned correctly. (#85)
- Trailing newline removal: Resolved inconsistent removal of trailing newlines when removing the closing tag. (#87)
Breaking Changes ⚠️
- PHP version requirement: The
format()
function now requires aPHPVersion
argument. This change is necessary to support theparentheses_around_new_in_member_access
option, which has version-specific behavior. (#89)
We hope you enjoy these improvements to the Mago formatter! 🎉
Full Changelog: 0.11.1...0.12.0
Mago 0.11.1
🐛 Bug Fixes
-
Linter Method Lookup Fix
Fixed an issue where the linter used original method casing (e.g.,doThing()
vsdothing()
) 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 #82
Fixed a bug in the Mago Composer plugin that caused it to ignore version constraints incomposer.json
and always install the latest version. It now honors the specified version range as expected.
Enjoy the stability improvements! 🛠️
Full Changelog: 0.11.0...0.11.1
Mago 0.11.0
Mago v0.11.0 Release Notes
✨ New Features
-
New Linter Rules
Added several best-practice and analysis rules to improve code quality:best-practices/no-else-clause
: Discourages the useelse
clause in anif
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 internalError
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
- Added scope tracking to lint context for more accurate analysis.
- Improved reflection handling for interfaces and tests.
🐛 Bug Fixes
-
Parser & Reflection Fixes
- Fixed parsing of expression string parts.
- Corrected method reflection to use lowercase names consistently.
- Resolved interface reflection issues.
-
Static Call Handling
- Allowed static calls to constructors and non-static methods within the same class or child classes.
-
CLI Fixes
- Fixed broken
mago fix
command functionality.
- Fixed broken
📚 Documentation
- CI Recipes
Added example CI configurations to streamline integration with GitHub workflows @nhedger in #79
🔧 Internal Changes
-
Serialization Cleanup
Removed serialization logic frominterner
andproject
crates. -
Source Management
Stub source names now prefixed with@
for clearer identification.
🚨 Breaking Changes
-
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: 0.10.0...0.11.0
Mago 0.10.0
✨ New Features
-
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
- Added support for PHP 7.3 and PHP 7.2.
- Updated the default PHP version to 8.4 when no explicit version is configured.
-
Experimental PHP Version Support
- New
allow_unsupported_php_version
configuration option enables running Mago with unsupported PHP versions (below 7.2 or above 8.4). - Functionality is not guaranteed for these versions—use at your own risk.
- New
🐛 Bug Fixes
- Parser Fix for Reserved Keywords
- Fixed an issue where the parser failed too early if a reserved keyword was used as a type name in a class or interface.
🔧 Internal Changes & Refactoring
-
Crate Merging & Cleanup
- Merged
reflector
andsemantics
into a singleproject
crate. - Removed
traverser
andsymbol-table
crates (mago_traverser
andmago_symbol_table
on crates.io).
- Merged
-
Walker Refactoring
- Simplified and improved walker implementations in the
project
crate.
- Simplified and improved walker implementations in the
-
Source Management Performance Fixes
- Addressed performance bottlenecks for smoother file handling.
🚀 Performance Improvements
-
Linter Performance
- 5% faster when running
mago lint
.
- 5% faster when running
-
Semantic Analysis Optimization
- 20-30% faster when running
mago lint -s
.
- 20-30% faster when running
Enjoy the updates! 🚀
Mago 0.9.1
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.
✨ New Features
🚫 @mago-ignore
Comment Support
This 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.
Syntax
@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.
Example
/**
* @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.
📝 Exclude Files from Formatting
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.
Example:
[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.
🛠 Bug Fixes
📝 Fix Trailing & Dangling Comments
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: 0.9.0...0.9.1
Mago 0.9.0
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 (#️⃣
).
🔥 Major Changes
1️⃣ Expanded Undefined Member Checks & Improved Severity Handling
Mago now detects more cases of undefined methods, functions, constants, and enum cases, preventing runtime errors before they happen.
New Checks Added:
✅ 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.
2️⃣ New CLI Command: 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.
How It Works
- Find where a symbol is used:
mago find SomeClass
- Search for function references:
mago find some_function
- Locate all trait usages:
mago find SomeTrait
- Works in user-defined & external sources
🎯 Built for speed & accuracy, this feature is ideal for navigating large codebases, understanding dependencies, and future LSP integrations.
📸 Example screenshots:


3️⃣ Overhauled Linter Rule System & Micro-Optimizations
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
Pull Requests
- refactor: overhaul linter rule system and micro-optimize crates by @azjezz in #66
- feat(lexer/linter): add support for #️⃣ hash emoji & corresponding linter rule by @azjezz in #67
- revert: remove emoji support in lexer and update NoHashEmojiRule by @azjezz in #68
- feat(linter): expand checks for undefined members & fix level handling by @azjezz in #70
- feat: introduce reference crate, and find cli command by @azjezz in #69
Full Changelog: 0.8.1...0.9.0
Mago 0.8.1
🐞 Bug Fixes
Type Hint Compatibility
- Fixed incorrect version checks for
null
andfalse
type hints:- Previously: Reported as PHP 8.2+ features
- Now: Correctly allows
null
andfalse
in union types for PHP 8.0+
Thanks to @Nadyita for reporting #65
✨ New Features
GitLab Issue Reporting
- Added support for GitLab-compatible issue reporting:
mago lint --reporting-format=gitlab
Thanks to @vvvinceocam for the contribution #62
Thank you for your feedback and contributions! 🚀
Full Changelog: 0.8.0...0.8.1
Mago 0.8.0
🚨 Breaking Changes
Removed compatibility
Plugin
- The
compatibility
plugin has been removed as its functionality is now integrated into the core semantics analyzer.
Strict PHP Version Checks
- New: The semantics analyzer now enforces strict PHP version compatibility.
- Detects usage of PHP features not available in the configured version
- Always results in an error (cannot be disabled or downgraded)
- Covers more features than the old plugin, ensuring stricter compliance
✨ New Features
PHP 8.5 Support
- Added support for new PHP 8.5 features:
- Closures in constant expressions
- Attributes on constants ( #64 )
Thank you for using Mago! 🚀
Full Changelog: 0.7.0...0.8.0