Release 5.0.0a3 supporting PHP 7.0-8.0 syntax
Pre-releaseJuly 15, 2021, Phan 5.0.0a3
Phan 5 introduces support for intersection types, and improves the accuracy of type casting checks and type inference to catch more issues.
This is the unstable branch for alpha releases of Phan 5. Planned/remaining work is described in #4413
If you are migrating from Phan 4, it may be useful to set up or update a Phan baseline file to catch issues such as nullable type mismatches.
https://github.com/phan/phan/wiki/Tutorial-for-Analyzing-a-Large-Sloppy-Code-Base has other advice on setting up suppressions.
For example, Phan is now more consistently warning about nullable arguments (i.e. both \X|null
and ?\X
) in a few cases where it may have not warned about passing \X|null
to a function that expects a non-null type.
If you are using plugins that are not part of Phan itself, they may have issues in Phan 5 due
to additional required methods being added to many of Phan's methods.
New Features (Analysis):
- Support parsing php 8.1 intersection types in php-ast 1.0.13+ (#4469)
(not yet supported in polyfill) - Support parsing php 8.1 first-class callable syntax in unreleased php-ast version (#4464)
- Support parsing php 8.1 readonly property modifier (#4463)
- Support allowing
new
expressions in php 8.1 readonly property modifier (#4460) - Emit
PhanTypeInvalidArrayKey
andPhanTypeInvalidArrayKeyValue
for invalid array key literal types or values. - Fix false positive
PhanTypeMissingReturn
/PhanPluginAlwaysReturnMethod
for method with phpdoc return type of@return never
- Warn about direct access to static methods or properties on traits (instead of classes using those methods/properties) being deprecated in php 8.1 (#4396)
- Add
Stringable
to allowed types for sprintf variadic arguments. This currently requires explicitly implementing Stringable. (#4466)
Bug fixes:
- Fix a crash when analyzing array literals with invalid key literal values in php 8.1.
- Fix a crash due to deprecation notices for accessing trait methods/properties directly in php 8.1