title: PHP Casting Variable as Object type in foreach Loop
body: <p>Within the following code, <code>$quiz_object-&gt;personalities</code> contains an array of <code>Personality</code> objects.</p>
  
  <pre><code>// Loop through each personality that exists for the quiz
  foreach($quiz_object-&gt;personalities AS $existing_personality)
  {
  
      // Show all of the existing personalities
      echo $existing_personality-&gt;GetQuizMakerPersonalityHTML();
  }
  </code></pre>
  
  <p>How do I "cast" (I think that's the right word) my variable <code>$existing_personality</code> within the foreach loop as the object type?</p>
  
  <p>I wish to do this so that when I type <code>$existing_personality-&gt;</code>, I get the list of public functions available for that object type.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>At the moment, Zend Studio doesn't know I am looping through an array of <code>Personality</code> objects within the loop, it just thinks it's a standard variable.  However, it is a type and my code works perfectly well.  I just want the IDE hints on my variable within the foreach loop.</p>
  
  <p>Just so that I'm clear, the hints appear for every other object, if I have:</p>
  
  <pre><code>$personality_object = new Personality();
  
  // I get the IDE hints here
  echo $personality_object-&gt;MyFunction();
  </code></pre>
  
  <p>But as soon as I start looping in a foreach, Zend has no way of knowing that I'm looping through an array of Objects.</p>
  
  <p>This is how the array of personalities is defined initially within my <code>Personality</code> object:</p>
  
  <pre><code>class Personality
  {
  
      // Array of Personality objects
      public $personalities = array();
  
  }
  </code></pre>