title: Why does a class that implements ArrayAccess, Iterator, and Countable not work with array_filter()?
body: <p>I have the following class: </p>
  
  <pre><code>&lt;?php
  
  /*
  * Abstract class that, when subclassed, allows an instance to be used as an array.
  * Interfaces `Countable` and `Iterator` are necessary for functionality such as `foreach`
  */
  abstract class AArray implements ArrayAccess, Iterator, Countable
  {
      private $container = array();
  
      public function offsetSet($offset, $value) 
      {
          if (is_null($offset)) {
              $this-&gt;container[] = $value;
          } else {
              $this-&gt;container[$offset] = $value;
          }
      }
  
      public function offsetExists($offset) 
      {
          return isset($this-&gt;container[$offset]);
      }
  
      public function offsetUnset($offset) 
      {
          unset($this-&gt;container[$offset]);
      }
  
      public function offsetGet($offset) 
      {
          return isset($this-&gt;container[$offset]) ? $this-&gt;container[$offset] : null;
      }
  
      public function rewind() {
              reset($this-&gt;container);
      }
  
      public function current() {
              return current($this-&gt;container);
      }
  
      public function key() {
              return key($this-&gt;container);
      }
  
      public function next() {
              return next($this-&gt;container);
      }
  
      public function valid() {
              return $this-&gt;current() !== false;
      }   
  
      public function count() {
       return count($this-&gt;container);
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>Then, I have another class that sub-classes AArray:</p>
  
  <pre><code>&lt;?php
  
  require_once 'AArray.inc';
  
  class GalleryCollection extends AArray { }
  
  ?&gt;
  </code></pre>
  
  <p>When I fill a GalleryCollection instance with data and then try to use it in <code>array_filter()</code>, in the first argument, I get the following error:</p>
  
  <pre><code>Warning: array_filter() [function.array-filter]: The first argument should be an array in
  </code></pre>