You don't need to change your code at all. You just need to tell the Hack tools about all the inbuilt PHP functions.
The easiest way to do this is to download this folder and put it somewhere in your project. I put it in a hhi folder in the base of my project. The files in there tell Hack about all the inbuilt PHP functions.
Most of them don't have type hints, which can lead to Hack thinking the return type of everything is mixed
instead of the actual return, that is actually correct in most cases as, for example, str_replace
can return either a string
or a bool
. However, it does stop the "unbound name" errors, which is the main reason for adding them.