This repository was archived by the owner on Dec 1, 2024. It is now read-only.
Repository navigation
4.13.0: add `instanceof` -> `is` migration, support current nightlies (4.14-dev)
This release:
- no longer uses
instanceofexpressions, supporting thedisable_instanceof_refinement=true.hhconfig option and current nightly builds (4.14-dev) of HHVM - requires HHVM 4.13 or above
- stops
hhast-migratelooking at non-hack files and git/hg data files if--include-vendoris passed - fixes
hhast-migrateignoring.hackfiles 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.