This release is packed with major improvements to the static analyzer, significantly boosting its accuracy and intelligence. We've fixed a whole class of tricky type resolution bugs and introduced a powerful new feature for inferring closure parameter types. We also fixed a critical bug that had disabled all linter rules in the previous version.
🚀 Features
- Precise Closure Parameter Type Inference: The analyzer is now much smarter when dealing with closures passed as arguments (e.g., to
array_map
). It can now infer the precise type of a closure's parameters from the call site, eliminating a wide range of false positive errors that occurred within closures. ( Closes #281 )
🐛 Fixes & Improvements
This release focuses heavily on correctness, with numerous fixes to the linter and analyzer.
Linter
- Linter Plugins Re-enabled: Fixed a critical bug from a recent refactoring that inadvertently disabled all linter plugins. All rules are now active again. (Closes #284)
override-attribute
Rule: The override rule has been corrected to ignore methods inside traits, preventing false positives.
Analyzer
- Union & Derived Types in Assertions: Fixed two critical bugs where the analyzer would fail to correctly resolve or compare complex types in
@psalm-assert
tags. Assertions with union types (e.g.,int|string
) and derived types (e.g.,value-of<T>
) are now handled correctly. readonly
Property Writes: The analyzer's rules forreadonly
properties have been aligned with the PHP engine. Apublic readonly
property is now correctly treated as havingprotected(set)
visibility, and writing to it outside of a constructor is now correctly flagged as an error.- Inherited
@require
Annotations: Fixed a bug where@require-implements
and@require-extends
annotations were not being checked when inherited from parent classes or traits.
Formatter
- Comment Placement: Corrected an issue where comments placed before ternary operators (
?
,:
) or match arm arrows (=>
) were being misplaced during formatting. (Closes #280)
🛠️ Chores & Refactoring
- Immutability Annotations Temporarily Removed: Support for
@immutable
,@mutation-free
, and related annotations has been temporarily removed. The previous implementation was not robust enough, and we plan to re-introduce these features with a more thorough design after the stable release. - Docs: Corrected a reference to
mago fix
in the documentation. (Thanks, @sasezaki! 🎉)
🤝 New Contributors
Full Changelog: 1.0.0-alpha.7...1.0.0-alpha.8