How to address "fatal error: call to a member function on null" in php?

Example:

$object = null;
$object->someFunction();
This error occurs when you try to call a function on an object that is null.

Solution:

if ($object !== null) {
    $object->someFunction();
}

Beginner's Guide to PHP