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

7 hours ago

Mago 1.0.0-beta.15

This is a huge release focused on deepening the analyzer's capabilities with best-in-class support for magic methods and properties. We've also landed a massive number of fixes and improvements for the formatter, resolving many regressions and significantly improving output quality for complex, real-world code.

A big thank you to our community for their amazing contributions to this release: @Bleksak, @dantleech, and @paulschreiber!

🪄 All-New Magic Method & Property Analysis

Mago's understanding of "magic" members defined via @method and @property docblocks has been completely overhauled. The new system is much stricter and provides far more accurate diagnostics for a wide range of common errors and patterns.

  • Full @method/@property Parsing: The analyzer now fully supports typed, untyped, read-only (@property-read), and write-only (@property-write) tags.
  • __call/__callStatic Validation: Mago now verifies that a class with magic docblocks has the required __call() or __callStatic() method to handle them, catching bugs that would lead to fatal runtime errors.
  • Dynamic Static Call Detection: A new check has been added to flag the fatal error of calling a @method static on an instance (e.g., $obj->magicStatic()).
  • Undocumented Access Warnings: The analyzer now issues a warning when accessing a potential magic member that isn't documented with a @method or @property tag, encouraging better, more analyzable code.

💅 Formatter Fixes & Polish

This release fixes numerous formatting regressions, restoring and improving upon the stability of earlier versions.

  • Complex Expression Formatting (#441, #428): The internal breaking logic has been significantly refactored, resolving a wide range of issues that caused poorly formatted output for complex, nested method chains and function calls.
  • New PHPUnit Assertion Style: The formatter now applies a specialized, more readable layout for PHPUnit assertion calls ($this->assertSame(...)).
  • Improved yield Formatting: The logic for yield key => value expressions has been improved to produce more compact and intelligent layouts, consistent with other assignments.

✨ Usability & CLI Improvements

  • Minimum Report Level: A new global flag, --minimum-report-level, has been added to all commands. This allows you to filter out diagnostics below a certain severity (e.g., --minimum-report-level=warning will hide note and help issues).
  • Multi-Code Pragmas: Suppression comments like @mago-expect and @mago-ignore now support a comma-separated list of issue codes (e.g., @mago-expect analysis:code-a,code-b).

🛠️ Other Analyzer & Linter Fixes

  • The analyzer is now much better at creating type assertions from built-in functions like count() and array_key_exists(), especially when they are aliased or used inside namespaces.
  • A missing visibility check for static method calls has been added. (#431)
  • Fixed a panic in the invalid-open-tag linter rule when encountering multi-byte UTF-8 characters like emojis. (#436)

🤝 New Contributors

Full Changelog: 1.0.0-beta.14...1.0.0-beta.15

Don't miss a new mago release

NewReleases is sending notifications on new releases.