Preempt fatal errors when making some function calls on an empty ArrayList

The function "first" on ArrayList uses the PHP function "reset", which
returns false if there aren't any elements in the array. Two functions
inside ArrayList use this function, "canFilterBy" and "byID". I've
changed these functions to catch the possibility of a false return from
first().
Merge pull request #2293 from robert-h-curry/empty-arraylist

Preempt fatal errors when making some function calls on an empty ArrayList