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

one day ago

Mago 1.0.0-beta.32

This is a massive stability and correctness release for the analyzer. We've significantly improved its ability to understand complex conditional logic and type hierarchies, leading to smarter type narrowing and the elimination of many false positives. As we get closer to the first release candidate, these foundational fixes are crucial for providing a reliable analysis experience.

A huge thank you to @baukevdw for their contribution to this release!

🚀 Smarter Conditional Type Analysis

The analyzer's ability to narrow types within if and match statements has been made much more powerful and correct.

  • Sealed Types (@psalm-inheritors) (#537): The analyzer now understands the @psalm-inheritors tag. When you check and negate an instanceof on a sealed interface or class, it will correctly infer the remaining possible types from the inheritor list. This is a huge improvement for codebases using algebraic data types.

  • Null Coalesce Assertions (??) (#531): The analyzer now correctly understands that a check like ($var ?? null) !== null guarantees that $var is both set and not null, eliminating false "possibly undefined" errors inside the if block.

  • Assignments in && Conditions (#538): Fixed a bug where a variable assigned on the right-hand side of an && in a condition was incorrectly reported as undefined.

  • Multiple isset() Assertions (#564): The analyzer now correctly processes all assertions in conditions with multiple isset() calls, like isset($a, $b) or isset($a) && isset($b).

🐞 Analyzer Soundness & Correctness

Several fundamental bugs in the type system and reconciler have been fixed to improve soundness.

  • !isset is null, not never (#570): A !isset() check now correctly reconciles the variable's type to null (or possibly_undefined), not never. This fixes a major bug that caused the analyzer to incorrectly mark valid code paths as unreachable.

  • Differentiated Null Array Access (#568): The analyzer now distinguishes between accessing an array on a variable that is definitely null (a NullArrayAccess error) versus one that is possibly null (a PossiblyNullArrayAccess warning). This provides more precise and appropriately severe feedback.

  • array vs Traversable (#563): A soundness issue was fixed where array was incorrectly treated as a subtype of Traversable. The type comparator now correctly distinguishes between them, fixing incorrect type narrowing for instanceof checks.

✨ New Configuration

  • New strict-list-index-checks Option (#565): A new configuration option, strict-list-index-checks (default: false), has been added. When enabled, it enforces that array list indices must be non-negative-int, providing stricter validation for users who want it.

🤝 New Contributors

Closed Issues


Full Changelog: 1.0.0-beta.31...1.0.0-beta.32

Don't miss a new mago release

NewReleases is sending notifications on new releases.