Do you consider foreach((array)$foo as $bar) a code smell?
<p>Do you consider this a code smell?</p>

<pre><code>foreach((array)$foo as $bar)
{
    $bar-&gt;doStuff();
}
</code></pre>

<p>Should i use that instead?</p>

<pre><code>if (isset($foo) &amp;&amp; is_array($foo))
{
    foreach($foo as $bar)
    {
        $bar-&gt;doStuff();
    }
}
</code></pre>

<p>Any other good practices to cover not set variables and assert an array?</p>
