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
<?hh /* -*- php -*- */
/**
 * Copyright (c) 2014, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the "hack" directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
const SUNFUNCS_RET_TIMESTAMP = '';
const SUNFUNCS_RET_STRING = '';
const SUNFUNCS_RET_DOUBLE = '';
function checkdate($month, $day, $year) {}
function date_default_timezone_get() {}
function date_default_timezone_set($timezone_identifier) {}
function date_parse_from_format($format, $date) {}
function date_parse($date) {}
function date_sun_info($time, $latitude, $longitude) {}
function date_sunrise($timestamp, $format = SUNFUNCS_RET_STRING, $latitude = "", $longitude = "", $zenith = "", $gmt_offset = 0) {}
function date_sunset($timestamp, $format = SUNFUNCS_RET_STRING, $latitude = "", $longitude = "", $zenith = "", $gmt_offset = 0) {}
function date($format, $timestamp = "") {}
function getdate($timestamp = "") {}
function gettimeofday($return_float = false) {}
function gmdate($format, $timestamp = "") {}
function gmmktime($hour = "", $minute = "", $second = "", $month = "", $day = "", $year = "", $is_dst = -1) {}
function gmstrftime($format, $timestamp = "") {}
function idate($format, $timestamp = "") {}
function localtime($timestamp = "", $is_associative = false) {}
function microtime($get_as_float = false) {}
function mktime($hour = "", $minute = "", $second = "", $month = "", $day = "", $year = "", $is_dst = -1) {}
function strftime($format, $timestamp = "") {}
function strptime($date, $format) {}
function strtotime($time, $now = "") {}
function time() {}
function timezone_name_from_abbr($abbr, $gmtOffset = -1, $isdst = -1) {}
function timezone_version_get() {}
class DateInterval {
    public $y;
    public $m;
    public $d;
    public $h;
    public $i;
    public $s;
    public $invert;
    public $days;
    public function createfromdatestring($time) {}
    public function format($format) {}
}
class DatePeriod implements Traversable {
    const EXCLUDE_START_DATE = 1;
}
class DateTime implements DateTimeInterface {
    const ATOM = "Y-m-d\TH:i:sP";
    const COOKIE = "l, d-M-Y H:i:s T";
    const ISO8601 = "Y-m-d\TH:i:sO";
    const RFC822 = "D, d M y H:i:s O";
    const RFC850 = "l, d-M-y H:i:s T";
    const RFC1036 = "D, d M y H:i:s O";
    const RFC1123 = "D, d M Y H:i:s O";
    const RFC2822 = "D, d M Y H:i:s O";
    const RFC3339 = "Y-m-d\TH:i:sP";
    const RSS = "D, d M Y H:i:s O";
    const W3C = "Y-m-d\TH:i:sP";
    public function add($object, $interval) {}
    public function __construct($time = "now", $timezone = null) {}
    public function createfromformat($format, $time, $timezone) {}
    public function getlasterrors() {}
    public function modify($object, $modify) {}
    public function __set_state($array) {}
    public function setdate($object, $year, $month, $day) {}
    public function setisodate($object, $year, $week, $day = 1) {}
    public function settime($object, $hour, $minute, $second = 0) {}
    public function settimestamp($object, $unixtimestamp) {}
    public function settimezone($object, $timezone) {}
    public function sub($object, $interval) {}
}
class DateTimeImmutable implements DateTimeInterface {
    public function add($interval) {}
    public function __construct($time = "now", $timezone = null) {}
    public function createfromformat($format, $time, $timezone) {}
    public function createfrommutable($datetime) {}
    public function getlasterrors() {}
    public function modify($modify) {}
    public function __set_state($array) {}
    public function setdate($year, $month, $day) {}
    public function setisodate($year, $week, $day = 1) {}
    public function settime($hour, $minute, $second = 0) {}
    public function settimestamp($unixtimestamp) {}
    public function settimezone($timezone) {}
    public function sub($interval) {}
}
class DateTimeInterface {
    public function diff($datetime1, $datetime2, $absolute = false) {}
    public function format($object, $format) {}
    public function getoffset($object) {}
    public function gettimestamp($object) {}
    public function gettimezone($object) {}
    public function __wakeup() {}
}
class DateTimeZone {
    const AFRICA = 1;
    const AMERICA = 2;
    const ANTARCTICA = 4;
    const ARCTIC = 8;
    const ASIA = 16;
    const ATLANTIC = 32;
    const AUSTRALIA = 64;
    const EUROPE = 128;
    const INDIAN = 256;
    const PACIFIC = 512;
    const UTC = 1024;
    const ALL = 2047;
    const ALL_WITH_BC = 4095;
    const PER_COUNTRY = 4096;
    public function __construct($timezone) {}
    public function getlocation($object) {}
    public function getname($object) {}
    public function getoffset($object, $datetime) {}
    public function gettransitions($object, $timestamp_begin, $timestamp_end) {}
    public function listabbreviations() {}
    public function listidentifiers($what = DateTimeZone::ALL, $country = null) {}
}
```
And with type hinting turned on. This was harder to solve as the docs are missing types and or values in certain areas.
```php
<?hh /* -*- php -*- */
/**
 * Copyright (c) 2014, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the "hack" directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
const SUNFUNCS_RET_TIMESTAMP = '';
const SUNFUNCS_RET_STRING = '';
const SUNFUNCS_RET_DOUBLE = '';
function checkdate(int $month, int $day, int $year): bool {}
function date_default_timezone_get(): string {}
function date_default_timezone_set(string $timezone_identifier): bool {}
function date_parse_from_format(string $format, string $date): array {}
function date_parse(string $date): array {}
function date_sun_info(int $time, float $latitude, float $longitude): array {}
function date_sunrise(int $timestamp, int $format = SUNFUNCS_RET_STRING, float $latitude = "", float $longitude = "", float $zenith = "", float $gmt_offset = 0): mixed {}
function date_sunset(int $timestamp, int $format = SUNFUNCS_RET_STRING, float $latitude = "", float $longitude = "", float $zenith = "", float $gmt_offset = 0): mixed {}
function date(string $format, int $timestamp = ""): string {}
function getdate(int $timestamp = ""): array {}
function gettimeofday(bool $return_float = false): mixed {}
function gmdate(string $format, int $timestamp = ""): string {}
function gmmktime(int $hour = "", int $minute = "", int $second = "", int $month = "", int $day = "", int $year = "", int $is_dst = -1): int {}
function gmstrftime(string $format, int $timestamp = ""): string {}
function idate(string $format, int $timestamp = ""): int {}
function localtime(int $timestamp = "", bool $is_associative = false): array {}
function microtime(bool $get_as_float = false): mixed {}
function mktime(int $hour = "", int $minute = "", int $second = "", int $month = "", int $day = "", int $year = "", int $is_dst = -1): int {}
function strftime(string $format, int $timestamp = ""): string {}
function strptime(string $date, string $format): array {}
function strtotime(string $time, int $now = ""): int {}
function time(): int {}
function timezone_name_from_abbr(string $abbr, int $gmtOffset = -1, int $isdst = -1): string {}
function timezone_version_get(): string {}
class DateInterval {
    public int $y;
    public int $m;
    public int $d;
    public int $h;
    public int $i;
    public int $s;
    public int $invert;
    public mixed $days;
    public function createfromdatestring(string $time): DateInterval {}
    public function format(string $format): string {}
}
class DatePeriod implements Traversable {
    const int EXCLUDE_START_DATE = 1;
}
class DateTime implements DateTimeInterface {
    const string ATOM = "Y-m-d\TH:i:sP";
    const string COOKIE = "l, d-M-Y H:i:s T";
    const string ISO8601 = "Y-m-d\TH:i:sO";
    const string RFC822 = "D, d M y H:i:s O";
    const string RFC850 = "l, d-M-y H:i:s T";
    const string RFC1036 = "D, d M y H:i:s O";
    const string RFC1123 = "D, d M Y H:i:s O";
    const string RFC2822 = "D, d M Y H:i:s O";
    const string RFC3339 = "Y-m-d\TH:i:sP";
    const string RSS = "D, d M Y H:i:s O";
    const string W3C = "Y-m-d\TH:i:sP";
    public function add(DateTime $object, DateInterval $interval): DateTime {}
    public function __construct(string $time = "now", ?DateTimeZone $timezone = null): DateTime {}
    public function createfromformat(string $format, string $time, DateTimeZone $timezone): DateTime {}
    public function getlasterrors(): array {}
    public function modify(DateTime $object, string $modify): DateTime {}
    public function __set_state(array $array): DateTime {}
    public function setdate(DateTime $object, int $year, int $month, int $day): DateTime {}
    public function setisodate(DateTime $object, int $year, int $week, int $day = 1): DateTime {}
    public function settime(DateTime $object, int $hour, int $minute, int $second = 0): DateTime {}
    public function settimestamp(DateTime $object, int $unixtimestamp): DateTime {}
    public function settimezone(DateTime $object, DateTimeZone $timezone): DateTime {}
    public function sub(DateTime $object, DateInterval $interval): DateTime {}
}
class DateTimeImmutable implements DateTimeInterface {
    public function add(DateInterval $interval): DateTimeImmutable {}
    public function __construct(string $time = "now", ?DateTimeZone $timezone = null): DateTimeImmutable {}
    public function createfromformat(string $format, string $time, DateTimeZone $timezone): DateTimeImmutable {}
    public function createfrommutable(DateTime $datetime): DateTimeImmutable {}
    public function getlasterrors(): array {}
    public function modify(string $modify): DateTimeImmutable {}
    public function __set_state(array $array): DateTimeImmutable {}
    public function setdate(int $year, int $month, int $day): DateTimeImmutable {}
    public function setisodate(int $year, int $week, int $day = 1): DateTimeImmutable {}
    public function settime(int $hour, int $minute, int $second = 0): DateTimeImmutable {}
    public function settimestamp(int $unixtimestamp): DateTimeImmutable {}
    public function settimezone(DateTimeZone $timezone): DateTimeImmutable {}
    public function sub(DateInterval $interval): DateTimeImmutable {}
}
class DateTimeInterface {
    public function diff(DateTimeInterface $datetime1, DateTimeInterface $datetime2, bool $absolute = false): DateInterval {}
    public function format(DateTimeInterface $object, string $format): string {}
    public function getoffset(DateTimeInterface $object): int {}
    public function gettimestamp(DateTimeInterface $object): int {}
    public function gettimezone(DateTimeInterface $object): DateTimeZone {}
    public function __wakeup(): void {}
}
class DateTimeZone {
    const int AFRICA = 1;
    const int AMERICA = 2;
    const int ANTARCTICA = 4;
    const int ARCTIC = 8;
    const int ASIA = 16;
    const int ATLANTIC = 32;
    const int AUSTRALIA = 64;
    const int EUROPE = 128;
    const int INDIAN = 256;
    const int PACIFIC = 512;
    const int UTC = 1024;
    const int ALL = 2047;
    const int ALL_WITH_BC = 4095;
    const int PER_COUNTRY = 4096;
    public function __construct(string $timezone): DateTimeZone {}
    public function getlocation(DateTimeZone $object): array {}
    public function getname(DateTimeZone $object): string {}
    public function getoffset(DateTimeZone $object, DateTime $datetime): int {}
    public function gettransitions(DateTimeZone $object, int $timestamp_begin, int $timestamp_end): array {}
    public function listabbreviations(): array {}
    public function listidentifiers(int $what = DateTimeZone::ALL, ?string $country = null): array {}
}
```