There is a concept in Hack called Nullable. It is used by prefixing the variable type with a question mark. So when you see ?bool $x you know that $x could be true, false or null.

This will help you to know what the type of you variables is. You don’t have to run tests to see if a function returns an empty array or null. Hopefully you will reduce your “Call to a member function x() on a non-object”-errors.

Keep in mind though, when you instantiating a class you must make sure to give a value to all the class variables that are not mark as Nullable. You must do this before you use any protected or public functions.