Skip to content

Releases: carthage-software/mago

Mago 0.17.0

06 Mar 13:05
36ecb44
Compare
Choose a tag to compare

Mago 0.17.0 🪄

This release of Mago brings new linting rules for Laravel, more formatter options, and bug fixes!

Laravel Linting 🔎

  • New Laravel rules: We've added three new linting rules to the Laravel plugin, helping you write cleaner and more idiomatic Laravel code (by @azjezz in #116):
    • **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.

Formatter Enhancements 🛠️

  • More control over formatting: Four new formatter options give you finer control over how your code is styled (by @azjezz in #114):
    • **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.

Bug Fixes 🐛

  • Member access chain comments: Fixed a bug where comments in member access chains were printed after the access operator instead of before. (by @azjezz in #113)
  • Match expression formatting: Fixed a bug that caused incorrect formatting of the default arm in match expressions. (by @azjezz in #112)
  • Binary expression indentation: Fixed a bug that caused incorrect indentation of multi-line binary expressions within parentheses. (by @azjezz in #111)
  • Arrow function formatting: Improved the formatting of arrow functions, including better handling of parentheses and argument list breaking. (by @azjezz in #109)

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: 0.16.0...0.17.0

Mago 0.16.0

04 Mar 09:10
10b8a37
Compare
Choose a tag to compare

Mago 0.16.0 🪄

This release of Mago focuses on refining the formatter and removing unused configuration options.

Formatter Improvements

  • Removed keyword_case option: Keywords will now always be formatted in lowercase, adhering to standard conventions and simplifying the configuration. (by @azjezz in #108)
  • Removed 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 afa1b33)
  • Added 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)

Other Changes

  • Fixed various formatting issues to ensure consistent and correct output for different code structures. (by @azjezz in #102, #103, #104, #105, #106, #107)

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: 0.15.0...0.16.0

Mago 0.15.0

03 Mar 05:09
3b13bf6
Compare
Choose a tag to compare

This release of Mago focuses on improving the developer experience (DX) with a new initialization command, enhanced configuration options, and bug fixes.

New Features

  • 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).

Bug Fixes

  • Token Precedence: Fixed a bug in the mago-token crate where the precedence of [ was incorrectly set, causing issues with parsing certain expressions.

Other Changes

  • Improved Test Coverage: Added more test cases for the formatter to ensure better code quality and prevent regressions.

This release makes Mago even more user-friendly and reliable. We hope you enjoy the new features and improvements!


Full Changelog: 0.14.0...0.15.0

Maog 0.14.0

01 Mar 04:25
dcc12a1
Compare
Choose a tag to compare

Formatter Enhancements 🛠️

  • 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.

Bug Fixes 🐛

  • CRLF handling on Windows: Fixed an issue where CRLF line endings were not handled correctly on Windows, leading to mixed line endings and other formatting inconsistencies.

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: 0.13.1...0.14.0

Mago 0.13.1

27 Feb 05:07
7d162ca
Compare
Choose a tag to compare

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

27 Feb 04:44
17f2cad
Compare
Choose a tag to compare

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 in 048fac1)
  • 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: The fix command has been deprecated in favor of lint --fix, simplifying the CLI and reducing redundancy. (by @azjezz in 10d2abb)

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

25 Feb 01:19
1e7555e
Compare
Choose a tag to compare

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 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 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 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: 0.11.1...0.12.0

Mago 0.11.1

21 Feb 20:56
f79f893
Compare
Choose a tag to compare

🐛 Bug Fixes

  • 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 #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: 0.11.0...0.11.1

Mago 0.11.0

21 Feb 01:54
8c94f8c
Compare
Choose a tag to compare

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 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

    • 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.

📚 Documentation

  • CI Recipes
    Added example CI configurations to streamline integration with GitHub workflows @nhedger in #79

🔧 Internal Changes

  • Serialization Cleanup
    Removed serialization logic from interner and project 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

16 Feb 02:36
1d5a58f
Compare
Choose a tag to compare

✨ 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.

🐛 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 and semantics into a single project crate.
    • Removed traverser and symbol-table crates (mago_traverser and mago_symbol_table on crates.io).
  • Walker Refactoring

    • Simplified and improved walker implementations in the project crate.
  • Source Management Performance Fixes

    • Addressed performance bottlenecks for smoother file handling.

🚀 Performance Improvements

  • Linter Performance

    • 5% faster when running mago lint.
  • Semantic Analysis Optimization

    • 20-30% faster when running mago lint -s.

Enjoy the updates! 🚀