Would it be better to force it to an array and let the rest of the code execute like normal? e.g.

```php
foreach ((array)$stats as $stat) {
   ...
}
```

Only problem is if `$stats` is an object, then it will be converted to an associative array... probably not something to worry about, though.