github carthage-software/mago 1.0.0-alpha.3
Mago 1.0.0-alpha.3

latest releases: 1.0.0-beta.10, 1.0.0-beta.9, 1.0.0-beta.8...
one month ago

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.

✨ New Features

  • New Linter Rule: 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.
  • Support for @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.

🛠️ Fixes & Improvements

  • Analyzer: Major 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)
  • Analyzer: Correct Array Shape Reconciliation
    Fixed a critical bug where assertions on array keys were not being applied correctly. After a condition like if (is_bool($data['x'])), the type of $data is now correctly narrowed from array{'x': mixed} to array{'x': bool}. (closes #256)
  • Docblock Parser: Complex Template Constraints
    The @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)
  • Formatter: Empty Statement Formatting
    The formatter no longer skips over empty statements (;), ensuring correct spacing and newline placement around consecutive or trailing semicolons. (closes #263)
  • Semantics: Short Open Tag (<?)
    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.
  • Analyzer: @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: 1.0.0-alpha.2...1.0.0-alpha.3

Don't miss a new mago release

NewReleases is sending notifications on new releases.