title: Array returned by getIterator in PHPs IteratorAggregate not traversable
body: <p>I am trying to make use of PHPs IteratorAggregate but not having much luck. The object that implements IteratorAggregate has a property $items which is an array of objects My_Object.</p>
  
  <p>When the users uses a foreach statement with instances of My_Collection I want it to iterate over the the $items array... However the code below does not appear to be working as expected. </p>
  
  <pre><code>class My_Object {
  
      public $value;
  
      public function __construct( $value ) {
          $this-&gt;value = $value;
      }
  
  }
  
  class My_Collection implements IteratorAggregate {
  
      protected $items = array();
  
      public function add_item( $value ) {
          array_push( $this-&gt;items, new My_Object( $value ) );
      }
  
      public function getIterator() {
          return $this-&gt;items;
      }
  }
  
  $my_collection = new My_Collection();
  $my_collection-&gt;add_item( 1 );
  $my_collection-&gt;add_item( 2 );
  $my_collection-&gt;add_item( 3 );
  
  foreach( $my_collection as $mine ) {
      echo( "&lt;p&gt;$mine-&gt;value&lt;/p&gt;" );
  }
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>&lt;b&gt;Fatal error&lt;/b&gt;:  Uncaught exception 'Exception' with message 'Objects returned by My_Collection::getIterator() must be traversable or implement interface Iterator' in [...][...]:29
  Stack trace:
  #0 [...][...](29): unknown()
  #1 {main}
  thrown in &lt;b&gt;[...][...]&lt;/b&gt; on line &lt;b&gt;29&lt;/b&gt;&lt;br /&gt;
  </code></pre>
  
  <p>Any help would be appreciated.</p>