Jun 26 2021, Phan 5.0.0a2
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):
- Improve accuracy of checks for weak type overlap for redundant condition warnings on
<=
- Emit
PhanAccessOverridesFinalConstant
when overriding a final class constant. (#4436) - Emit
PhanCompatibleFinalClassConstant
if class constants have the final modifier in codebases supporting a minimum target php version older than 8.1 (#4436) - Analyze class constants declared in interfaces as if they were final in php versions prior to 8.1. (#4436)
- Warn about using $this or superglobals as a parameter or closure use. (#4336)
New Features (CLI)
- Use
var_representation
/polyfill for generating representations of values in issue messages.
Maintenance:
- Upgrade tolerant-php-parser from ^0.0.23 to ^0.1.0 to prepare to support new php syntax in the polyfill/fallback parser. (#4449)
Bug fixes:
- Properly warn about referencing $this from a
static fn
declared in an instance method. (#4336) - Fix a crash getting template parameters of intersection types