One function with two distinct modes should just be two separate functions (one that does not take an $item, and one that requires an $item). Also, per documentation, $item cannot be null.