Support PHP-decl mode
Support reading a `<?php` file as decl mode. This might seem
weird, but hear me out.
We need a good story around how 3rd party libraries, who may love Hack
and want to be maximally Hack compatible, can still remain compatible
with upstream PHP-5. The best we have right now is hhi, but those can
easily get out of sync with reality. We might also be able to build a
Hack => PHP type erasure tool, but then we create a new subset of the
language -- whatever PHP-5 supports, minus types. (Unless we built a
much more complicated tool that dealt with collections, short lambdas,
etc, which is a can of worms I really don't want to open.)
This solves the compatibility problem. If your code is largely
Hack-clean, you can at least let the typechecker suck in your class and
function definitions for any users of your library. But we do this
without creating a new subset of Hack or even really without defining a
new Hack mode -- this is just standard `decl` mode, but it happens to be
in a PHP file. We can even suck in PHP-5-compatible type information, if
you have any. (Creating a new subset of the language is an argument
against `<?php // partial`, which is technically easy to implement but
probably not directionally where we want to take the language.)
Basically, this means we can morally pull an HHI-like interface directly
out of your PHP source, if you are Hack-aware and add the annotation for
us.
Massive props to GitHub users pvh and naderman for coming up with this
idea during Hack dev day.
Reviewed By: @gabelevi
Differential Revision:
D1268908