packagist phan/phan 2.4.7
Release 2.4.7 supporting PHP 7.0-7.4 syntax

latest releases: v5.x-dev, dev-fix-4782, dev-MapReal-php81-82...
4 years ago

New features(CLI, Configs):

  • Add an environment variable PHAN_NO_UTF8=1 to always avoid UTF-8 in progress bars.
    This may help with terminals or logs that have issues with UTF-8 output.
    Error messages will continue to include UTF-8 when part of the error.
  • Allow phan --init to complete even if composer.json has no configured autoload directories,
    as long as at least one directory or file was configured.
  • Add a setting error_prone_truthy_condition_detection that can be enabled to warn about error-prone truthiness/falsiness checks. New issue types:
    • PhanSuspiciousTruthyCondition (e.g. for if ($x) where $x is object|int)
    • PhanSuspiciousTruthyString (e.g. for ?string - '0' is also falsey in PHP)
  • Limit calculation of max memory usage to the running worker processes with --processes N (#3606)
  • Omit options that should almost always be on (e.g. analyze_signature_compatibility) from the output of phan --init (#3660)
  • Allow phan --init to create config file with target_php_version of '7.4' or '8.0' based on composer.json (#3671)

New Features(Analysis):

  • Infer that merging defined variables with possibly undefined variables is also possibly undefined. (#1942)
  • Add a fallback when some types of conditional check results in a empty union type in a loop:
    If all types assigned to the variable in a loop in a function are known,
    then try applying the condition to the union of those types. (#3614)
    (This approach was chosen because it needs to run only once per function)
  • Infer that assignment operations (e.g. +=) create variables if they were undefined.
  • Properly infer that class constants that weren't literal int/float/strings have real type sets in their union types.
  • Normalize union types of generic array elements after fetching $x[$offset].
    (e.g. change bool|false|null to ?bool)
  • Normalize union types of result of ?? operator.
  • Fix false positives in redundant condition detection for the real types of array accesses. (#3638, #3645, #3650)
  • Support the non-empty-string type in phpdoc comments (neither '' nor '0').
    Warn about redundant/impossible checks of non-empty-string.
  • Support the non-zero-int type in phpdoc comments. Infer it in real types and warn about redundant checks for zero/truthiness.
  • Support the the non-empty-mixed in phpdoc comments and in inferences.
  • Fix false positives possibly undefined variable warnings after conditions
    such as if (X || count($x = [])), if (X && preg_match(..., $matches)), etc.

Bug fixes:

  • Fix a crash analyzing assignment operations on $GLOBALS such as $GLOBALS['var'] += expr; (#3615)
  • Fix false positive Phan[Possibly]UndeclaredGlobalVariable after conditions such as assert($var instanceof MyClass when the variable was not assigned to within the file or previously analyzed files. (#3616)
  • Fix line number of 0 for some nodes when simplify_ast is enabled. (#3649)

Plugins:

  • Make Phan use the real type set of the return value of the function being analyzed when plugins return a union type without a real type set.

Maintenance:

  • Infer that explode() is possibly the empty list when $limit is possibly negative. (#3617)
  • Make Phan's code follow more PSR-12 style guidelines
    (<?php on its own line, function(): T instead of function() : T, declare visibility for class constants)
  • Internal: Check if strings are non-zero length in Phan's implementation instead of checking for variable truthiness.
    ('0' is falsey)
  • Show null as lowercase instead of uppercase (the way var_export renders it) in more places.

Don't miss a new phan release

NewReleases is sending notifications on new releases.