Skip to content

Release 2.4.3 supporting PHP 7.0-7.4 syntax

Compare
Choose a tag to compare
@TysonAndre TysonAndre released this 21 Nov 01:03
· 914 commits to master since this release
c1e1c2d

New features(CLI, Configs):

  • Support NO_COLOR environment variable. (https://no-color.org/)
    When this variable is set, Phan's error message and issue text will not be colorized unless the CLI arg --color or -c is used.
    This overrides the PHAN_ENABLE_COLOR_OUTPUT setting.
  • Add PHAN_DISABLE_PROGRESS_BAR environment variable to disable progress bar by default unless the CLI arg --progress-bar is used.
  • Show an extra decimal digit of precision in the progress bar when the terminal is wide enough. (#3514)

New features(Analysis):

  • Make inferred real types more accurate for equality/identity/instanceof checks.

  • Combine array shape types into a single union type when merging variable types from multiple branches. (#3506)
    Do a better job of invalidating the real union type of fields of array shape types when the field is only checked/set on some code branches.

  • Make issue suggestions (and CLI suggestions) for completions of prefixes case-insensitive.

  • Support @seal-properties and @seal-methods as aliases of @phan-forbid-undeclared-magic-properties and @phan-forbid-undeclared-magic-methods

  • More aggressively infer real types of array destructuring(e.g. [$x] = expr) and accesses of array dimensions (e.g. $x = expr[dim]) (#3481)

    This will result in a few more false positives about potentially real redundant/impossible conditions and real type mismatches.

  • Fix false positives caused by assuming that the default values of properties are the real types of properties.

  • Infer that globals used in functions (global $myGlobal;) have unknown real types - don't emit warnings about redundant/impossible conditions. (#3521)

Plugins:

  • Also start checking if closures (and arrow functions) can be static in PossiblyStaticMethodPlugin
  • Add AvoidableGetterPlugin to suggest when $this->prop can be used instead of $this->getProp().
    (This will suggest using the property instead of the getter method if there are no known method overrides of the getter. This is only checked for instance properties of $this)
  • Increase severity of PhanPluginPrintfNonexistentArgument to critical. It will become an ArgumentCountError in PHP 8.

Maintenance:

  • Bump minimum version of netresearch/jsonmapper to avoid php notices in the language server in php 7.4
  • Improve worst-case performance when analyzing code that has many possible combinations of array shapes.

Bug fixes:

  • Properly emit redundant and impossible condition warnings about uses of class constants defined as literal strings/floats/integers.
    (i.e. infer their real union types)
  • Fix false positive inference that $x[0] was string for $x of types such as list<\MyClass>|string (reported in #3483)
  • Consistently inherit analysis settings from parent classes recursively, instead of only inheriting them from the direct parent class. (#3472)
    (settings include presence of dynamic properties, whether undeclared magic methods are forbidden, etc.)
  • Don't treat methods that were overridden in one class but inherited by a different class as if they had overrides.
  • Fix a crash when running in php 8.0.0-dev due to Union Types being found in Reflection. (#3503)
  • Fix edge case looking up the extends class/interface name when the namespace is a use alias (#3494)