facebook/hhvm — pull request #3707 by milesj (2014-09-09 05:03:02+00:00)
Title: hhi generator script

Instead of going through all the hhi files manually and fixing/adding any declarations, I got pretty bored and wrote this hhi generator tool. The tool will generate hhi files based on the official PHP docs and will require the docs SVN repository located here: https://svn.php.net/repository/phpdoc/modules/doc-en

Once you have the repository checked out, you can run the script with the command below. By default this will output all files to the `hphp/hack/hhi/stdlib/` folder, so be sure to backup the previous folder. You can change the destination folder with `--dest=`.

```
./generate-hhi.py --src=/path/to/svn/checkout
```

If you pass `--type-hint` as an option, it will add type hinting to arguments and returns (also applies correct nullables).

This tool isn't 100% solid as there are errors in the PHP docs (go figure) but I tried to solve as many as the common issues as possible. The tool also does not handle namespaces well nor does it preserve any custom hhi code that was previously written (like generics or async).

But for the most part, it handles a large portion of the conversion process. I also didn't want to completely finish the script as there may be requirements that I do not know about. May be better for you to finalize the rest of this (if you find it useful).

Here's an example output with type hinting turned off:

```php