Mago 1.0.0-beta.11
This release introduces support for new PHP features, adds stubs for the php-decimal
extension, and fixes several bugs in type inference and assertion logic.
🚀 Features
- Flexible Linter Configuration: You can now configure linter rule levels in your
mago.toml
file using common lowercase aliases. For example, instead of just"Error"
, you can now use"error"
,"err"
, or"deny"
. This makes configuration more intuitive and consistent with other tools. (#381 by @azjezz) - PHP 8.5
#[Deprecated]
on Traits: Mago now recognizes the#[Deprecated]
attribute on traits, a new feature in PHP 8.5. (#386 by @DanielEScherzer) php-decimal
Extension Support: Stubs for thephp-decimal
extension have been added to the prelude, improving analysis accuracy for projects that use this extension. (#397 by @Bleksak)
🐛 Bug Fixes
- Array Key Existence: The analyzer's understanding of array key checks has been significantly improved.
- Functions like
array_key_exists()
,key_exists()
, andPsl\Iter\contains_key()
now correctly inform the type system that a key exists after being checked. (#392 by @Bleksak) - Fixed a bug where checking for the existence of one array key (e.g.,
isset($a['foo'])
) would incorrectly imply that a different key also exists. (#393, #394 by @Bleksak)
- Functions like
unset()
on Lists: Fixed a type inference bug where usingunset()
on an element of alist<T>
would incorrectly preserve thelist
type. The type is now correctly widened toarray<int, T>
, reflecting that the keys may no longer be sequential. (#396 by @azjezz)- Exact Count Assertions: Conditions that check for an exact item count (e.g.,
count($array) === 1
) now correctly narrow the array's type to be non-empty. (#388 by @azjezz) - Refined
end()
Stub: The return type annotation for the built-inend()
function has been made more precise, correctly distinguishing between the return types for empty and non-empty arrays. (#387 by @Bleksak) sizeof()
Alias: The function stub forsizeof()
now exactly mirrorscount()
, as it's a direct alias, ensuring consistent type analysis. (#389 by @Bleksak)
🔧 Internal Changes
- Test Suite Improvements: The analyzer's test suite now uses a shared
mago-prelude
for built-in PHP stubs. This reduces boilerplate in test files and ensures that tests run against the same definitions used in production analysis. (by @azjezz)
🤝 New Contributors
- @DanielEScherzer made their first contribution in #386
Full Changelog: 1.0.0-beta.10...1.0.0-beta.11