github carthage-software/mago 1.0.0-beta.28
Mago 1.0.0-beta.28

15 hours ago

Mago 1.0.0-beta.28

This release is packed with significant correctness fixes for the analyzer, focusing on advanced type system features like enums, generics, and traits. The formatter also receives critical bug fixes for operator precedence and brace placement.

A massive thank you to our community for driving this release forward with their contributions: @bendavies, @yankewei, @dragosprotung, and @muro3r!

🚀 Analyzer Correctness Fixes

The analyzer's accuracy has been substantially improved with fixes for several fundamental type system and control flow bugs.

  • Enum Method Analysis (#546): The analyzer now synthetically generates full metadata for built-in enum methods (from, tryFrom, cases). This provides precise parameter and return types, enabling correct analysis of first-class callables like Category::from(...).

  • Template & Type System Correctness:

    • Inherited Templates (#535): Template types defined via extends or implements on an interface or class are now correctly resolved and applied.
    • enum_exists Narrowing (#541): Fixed a bug where intersecting a specific class with a generic type would incorrectly discard the more specific class information, improving type narrowing after checks like enum_exists().
    • count() Assertions (#540): Assertions from count() calls (e.g., if (count($arr) > 0)) are now correctly applied, allowing the analyzer to understand that an array is non-empty.
  • Flow PHP Types Support (#527): Added special handling for the flow-php/types library, including support for its type_structure() function. (Thanks, @bendavies!)

  • Imagick Support (#543): The analyzer now has stubs for Imagick class constants, improving type safety when working with the Imagick extension. (Thanks, @dragosprotung!)

💅 Formatter Fixes

  • Operator Precedence with clone (#536): Fixed a critical bug where the formatter would incorrectly remove parentheses from a ternary expression inside a clone() call, which would change the code's behavior. The logic is now more robust for other unary constructs as well.

  • Brace Placement (#545): Corrected an issue where the opening brace for functions or methods with long signatures but short parameter lists was being placed on the same line, violating the NextLine brace style.

✨ Linter Updates

  • yoda-conditions Rule Disabled by Default (#505): In response to community feedback, the yoda-conditions rule is now disabled by default. It was found to be too noisy for many projects, and its primary goal of preventing accidental assignments is already covered by the no-assign-in-condition rule. Teams that prefer this style can still enable it in their mago.toml.

  • New Rule: no-variable-variable: A new rule has been added to disallow the use of variable-variables (e.g., $$foo), which can make code difficult to understand and analyze.

  • no-redundant-use Improvements: This rule has been improved to understand Tempest view classes, reducing false positives in projects using this framework. (#532)

🤝 New Contributors


Full Changelog: 1.0.0-beta.27...1.0.0-beta.28

Don't miss a new mago release

NewReleases is sending notifications on new releases.