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 aninstanceof
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 theif
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 multipleisset()
calls, likeisset($a, $b)
orisset($a) && isset($b)
.
🐞 Analyzer Soundness & Correctness
Several fundamental bugs in the type system and reconciler have been fixed to improve soundness.
-
!isset
isnull
, notnever
(#570): A!isset()
check now correctly reconciles the variable's type tonull
(orpossibly_undefined
), notnever
. 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
(aNullArrayAccess
error) versus one that is possiblynull
(aPossiblyNullArrayAccess
warning). This provides more precise and appropriately severe feedback. -
array
vsTraversable
(#563): A soundness issue was fixed wherearray
was incorrectly treated as a subtype ofTraversable
. The type comparator now correctly distinguishes between them, fixing incorrect type narrowing forinstanceof
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 benon-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