title: How can I get intellisense in PHP/Eclipse on custom objects pulled out of array in foreach loop?
body: <p>I have a collection of <strong>custom objects</strong> (Podcast) in an array.</p>
  
  <p>When I use a <strong>foreach</strong> loop to iterate through this collection, I don't have <strong>code completion</strong> on the variable that contains the object pulled out of the collection (as I would in C#/VisualStudio for instance).</p>
  
  <p><strong>Is there a way to give PHP a type hint so that Eclipse knows the type of the object being pulled out of the collection so it can show me the methods on that object in intellisense?</strong></p>
  
  <p><img src="https://i.stack.imgur.com/m1MvE.png" alt="alt text"></p>
  
  <pre><code>&lt;?php
  
  $podcasts = new Podcasts();
  echo $podcasts-&gt;getListHtml();
  
  class Podcasts {
      private $collection = array();
  
      function __construct() {
          $this-&gt;collection[] = new Podcast('This is the first one');
          $this-&gt;collection[] = new Podcast('This is the second one');
          $this-&gt;collection[] = new Podcast('This is the third one');
      }
  
      public function getListHtml() {
          $r = '';
          if(count($this-&gt;collection) &gt; 0) {
              $r .= '&lt;ul&gt;';
              foreach($this-&gt;collection as $podcast) {
                  $r .= '&lt;li&gt;' . $podcast-&gt;getTitle() . '&lt;/li&gt;';
              }
              $r .= '&lt;/ul&gt;';
          }       
          return $r;
      }
  }
  
  class Podcast {
  
      private $title;
  
      public function getTitle() { return $this-&gt;title; }
      public function setTitle($value) {  $this-&gt;title = $value;}
  
      function __construct($title) {
          $this-&gt;title = $title;
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <h1>Addendum</h1>
  
  <p>Thanks, Fanis, I updated my FOREACH template to include that line automatically:</p>
  
  <pre><code>if(count(${lines}) &gt; 0) {
      foreach(${lines} as ${line}) {
          /* @var $$${var} ${Type} */
  
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/osLdr.png" alt="alt text"></p>