phan v3.2.0 Release Notes

Release Date: 2020-08-25 // over 3 years ago
  • ๐Ÿ†• New features (CLI, Config):

    โž• Add the minimum_target_php_version config setting and --minimum-target-php-version CLI flag. (#3939)
    Phan will use this instead of target_php_version for some backwards compatibility checks
    ๐Ÿ‘ (i.e. to check that the feature in question is supported by the oldest php version the project supports).

    ๐Ÿ”ง If this is not configured, Phan will attempt to use the composer.json version ranges if they are available.
    Otherwise, target_php_version will be used.

    Phan will use target_php_version instead if minimum_target_php_version is greater than target_php_version.

    Update various checks to use minimum_target_php_version instead of target_php_version.

    โž• Add --always-exit-successfully-after-analysis flag.
    0๏ธโƒฃ By default, phan exits with a non-zero exit code if 1 or more unsuppressed issues were reported.
    When this CLI flag is set, phan will instead exit with exit code 0 as long as the analysis completed.

    Include the installed php-ast version and the php version used to run Phan in the output of phan --version. (#4147)

    ๐Ÿ†• New features (Analysis):

    Emit PhanCompatibleArrowFunction if using arrow functions with a minimum target php version older than php 7.4.

    Emit PhanCompatibleMatchExpression if using match expressions with a minimum target php version older than php 8.0.

    Emit PhanNoopRepeatedSilenceOperator for @@expr or @(@expr).
    This is less efficient and only makes a difference in extremely rare edge cases.

    Avoid false positives for bitwise operations on floats such as unsigned 64-bit numbers (#4106)

    ๐Ÿ‘ Incomplete support for analyzing calls with php 8.0's named arguments. (#4037)
    New issue types: PhanUndeclaredNamedArgument*, PhanDuplicateNamedArgument*,
    PhanMissingNamedArgument*,
    PhanDefinitelyDuplicateNamedArgument, PhanPositionalArgumentAfterNamedArgument, and
    PhanArgumentUnpackingUsedWithNamedArgument, PhanSuspiciousNamedArgumentForVariadic

    ๐Ÿ‘ Incomplete support for analyzing uses of PHP 8.0's nullsafe operator(?->) for property reads and method calls. (#4067)

    Warn about using @var where @param should be used (#1366)

    Treat undefined variables as definitely null/undefined in various places
    when they are used outside of loops and the global scope. (#4148)

    Don't warn about undeclared global constants after defined() conditions. (#3337)
    Phan will infer a broad range of types for these constants that can't be narrowed.

    ๐Ÿ“œ Parse lowercase-string and non-empty-lowercase-string in phpdoc for compatibility, but treat them like ordinary strings.

    Emit PhanCompatibleTrailingCommaParameterList and PhanCompatibleTrailingCommaArgumentList when the polyfill is used. (#2269)
    Trailing commas in argument lists require a minimum target version of php 7.3+,
    and trailing commas in parameters or closure use lists require php 8.0+.

    ๐Ÿ“œ This is only available in the polyfill because the native php-ast parser
    ๐Ÿ”ฆ exposes the information that php itself tracks internally,
    and php deliberately does not track whether any of these node types have trailing commas.

    There are already other ways to detect these backwards compatibility issues,
    such as --native-syntax-check path/to/php7.x.

    Warn about variable definitions that are unused due to fallthroughs in switch statements. (#4162)

    ๐Ÿ”Œ Plugins:

    • โž• Add more aliases to DeprecateAliasPlugin

    Miscellaneous:

    • ๐Ÿš‘ Raise the severity of PhanUndeclaredConstant and PhanStaticCallToNonStatic from normal to critical.
      Undeclared constants will become a thrown Error at runtime in PHP 8.0+.

    ๐Ÿ› Bug fixes:

    • Suppress PhanParamNameIndicatingUnused in files loaded from autoload_internal_extension_signatures
    • ๐Ÿ‘Œ Improve compatibility of polyfill/fallback parser with php 8.0
    • Also try to check against the realpath() of the current working directory when converting absolute paths
      to relative paths.
    • ๐Ÿ Generate baseline files with / instead of \ on Windows in --save-baseline (#4149)