Skip to content

Release 5.0.0a1 supporting PHP 7.0-8.0 syntax

Pre-release
Pre-release
Compare
Choose a tag to compare
@TysonAndre TysonAndre released this 30 May 15:01
· 412 commits to v5 since this release
8e458c3

May 30 2021, Phan 5.0.0a1

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 intersection types in phpdoc and checking if intersection types satisfy type comparisons
  • Support inferring intersection types from conditions such as instanceof
  • Warn about impossible type combinations in phpdoc intersection types.
    New issue types: PhanImpossibleIntersectionType
  • Improve type checking precision for whether a type can cast to another type.
  • Improve precision of checking if a type is a subtype of another type.
  • Split out warnings about possibly invalid types for property access (non-object) and possibly invalid classes for property access
    New issue types: PhanPossiblyUndeclaredPropertyOfClass
  • Also check for partially invalid expressions for instance properties during assignment (PhanPossiblyUndeclaredProperty*)
  • Treat @template-covariant T as an alias of @template T - Previously, that tag was not parsed and T would be treated like a (probably undeclared) classlike name. (#4432)

Bug fixes:

  • Fix wrong expression in issue message for PhanPossiblyNullTypeMismatchProperty (#4427)

Breaking Changes:

  • Many internal methods now require a mandatory CodeBase instance. This will affect third party plugins.
  • Remove --language-server-min-diagnostic-delay-ms.