title: PHP 5.6 to PHP 5.4 downgrade: iterators no longer working
body: <p>I have a website which was working fine in XAMPP with PHP 5.6.</p>
  
  <pre><code>foreach ($treeNodeIterator as $nodeKey =&gt; $node) {
  
    $currentLevel = $nodeKey-&gt;getNodeLevel();
  
    if ($currentLevel &gt; $depth) {
  
      $depth = $currentLevel;
  
    }
  
  }
  </code></pre>
  
  <p>I then found out my server was running PHP 5.4. So now I get
  the following error message on the server log file:</p>
  
  <pre><code>[13-Sep-2015 12:33:19 America/Denver] PHP Fatal error:  Call to a member function getNodeLevel() on a non-object in treeNode.php line 82
  </code></pre>
  
  <p>Here is the TreeNodeIteratorKey class:</p>
  
  <pre><code>class TreeNode {
  
    protected $name;
  
    protected $value;
  
    protected $children;
  
    protected $customData;
  
    //...
  
  }
  
  class TreeNodeIterator implements Iterator {
  
    private $traversalMode;
  
    private $rootNode;
  
    private $nodesToVisit;
  
    private $nodesToVisitLevels;
  
    private $currentNodeIteratorKey;
  
    const TRAVERSAL_MODE_BFS = 0;
  
    const TRAVERSAL_MODE_DFS = 1;
  
    const NUM_TRAVERSAL_MODES = 2;
  
    public function current() {
  
      return $this-&gt;nodesToVisit[0];
  
    }
  
    public function key() {
  
      return $this-&gt;currentNodeIteratorKey;
  
    }
  
  
  }
  
  class TreeNodeIteratorKey {
  
    private $nodeIndex;
  
    private $nodeLevel;
  
    private $customData;
  
    //...
  }
  </code></pre>