I think you can typehint $userGroups with \ Traversable