Mago 1.51.0 adds Swoole stubs and improves type analysis, with fixes for static locals, loop types, boolean guards, lint suggestions, and formatting.
Note
Support Mago
Does your company use Mago? Please consider sponsoring its development. We need funding to keep improving Mago, fixing bugs, and shipping releases.
Sponsor Mago ❤️
✨ Features
Prelude
🐛 Bug Fixes
Analyzer
- Static locals: tracks values across calls, including array keys added after initialization. (#2403, 452721b)
- Invokable results: checks discarded
__invokeresults marked#[NoDiscard]or@must-use. (#2400, f01b94e) - Loop replacements: keeps new element types when a loop replaces every array value. (#2366, #2386, 2e560fa)
- Unchanged arrays: preserves shapes and tuples after loops that leave their values unchanged. (#2409, 9608b8c)
- Finally assignments: keeps types and definedness from assignments in
finallyblocks. (#2410, 71764f0) - Boolean guards: retains narrowing when a flag starts outside an
ifand changes in one branch. (#2411, 0d0224d)
Codex
- String intersections: combines string refinements, including those in conditional types. (#2401, #2402, 4808b0a)
Linter
- Self return types: skips intersection types to avoid fixes that cause PHP fatal errors. (#2405, 185644f)
- Destructuring: keeps short arrays in assignment targets and nested
list(). (#2407, #2408, a11d5e3, 5d804d7) - Drupal hook names: leaves
hook_*names in*.api.phpunchanged with Drupal integration. (#2390, #2391, 335d8a7) - WordPress output: checks short echo tags and recognizes more WordPress escaping functions. (#2397, 245c4a2)
Formatter
- Closing tags: keeps
?>after method chains with a semicolon on its own line. (#2393, 17cc593) - Class constant arguments: wraps long calls whose sole argument is a class constant. (#2183, #2406, 22e0128)
Configuration
- Shared configuration: replaces inherited extension commands and adds
extendsto the schema. (#2354, 8556e0e)
Prelude
str_increment: marks its return type asnon-empty-string. (452721b)
Syntax
- Braced interpolation: avoids repeated scans of nested string interpolation in the lexer. (de4c9b8)
📖 Documentation
Reference
- Rule option types: shows nullable numeric options as
number or null, using the schema. (#2398, 7ceff94) - Syntax tree names: uses CST consistently in docs and code comments. (#2327, 56b8844)
🧩 Extension Protocol
No protocol changes in this release.
🙏 Thank You
Contributors
A huge thank you to everyone who contributed to this release:
- @mleczakm: #2298
- @Soean: #2402
- @shuvroroy: #2386
- @rlorenzo: #2397, #2407, #2408
- @amateescu: #2391
- @bastnic: #2393
- @ynaamane: #2406
- @Neirda24: #2353, #2354
- @klausi: #2398
- @maximal: #2327
Issue Reporters
Thank you to everyone who reported issues that shaped this release:
- @mytskine: #2403
- @bendavies: #2400
- @MichaelOwenDyer: #2366
- @UweOhse: #2409, #2410, #2411
- @Soean: #2401
- @simon-mundy: #2405
- @amateescu: #2390
- @maximal: #2183
Full Changelog: 1.50.0...1.51.0