Call to a member function isDocument() on null