Skip to content

@fredemmott fredemmott released this Jul 12, 2019 · 7 commits to v4.13.x since this release

This release:

  • no longer uses instanceof expressions, supporting the disable_instanceof_refinement=true .hhconfig option and current nightly builds (4.14-dev) of HHVM
  • requires HHVM 4.13 or above
  • stops hhast-migrate looking at non-hack files and git/hg data files if --include-vendor is passed
  • fixes hhast-migrate ignoring .hack files if migrating an entire directory
  • adds bin/hhast-migrate --instanceof-is

--instanceof-is replaces expressions of the form $foo instanceof Bar with $foo is Bar, $foo is Bar<_>, $foo is Bar<_, _> etc, depending on how many generics Bar has.

This can lead to additional type errors for code that was already unsafe; for example:

class SomeClass<T> {}

function foo(SomeClass<string> $a): void {}

function bar(mixed $a): void {
  if ($a instanceof SomeClass) {
     foo($a); // this is unsafe, but does not raise a type error
  if ($a is SomeClass<_>) {
    foo($a); // also unsafe, but does raise a type error

If HHAST is unable to find the definition of the class, it will assume that it takes no generics.

It does not migrate expressions of the form $foo instanceof $bar, as there is no consistent 'best' replacement; these need manually fixing.

Assets 2
You can’t perform that action at this time.