Going through the ArrayObject here as well in case that's what this is, it doesn't implement Iterator directly, only Traversable, so if it were an arrayobject you cannot use next, valid, or current on it. Given the original implementation would indicate this is a custom object, not a Traversable one.
So the first thing you need to do is figure out what this is supposed to be. Since you are manipulating the globals (which you shouldn't be doing), you'll need to trace the code back to the creation of this variable, then evaluate the function getUsers within it to see what is possible to return. Then you can use if/else blocks to determine what to do with it.