public function next($cssSelector = null) { // if ($cssSelector || $this->valid) // return $this->_next($cssSelector); $this->valid = isset($this->elementsInterator[$this->current + 1]) ? true : false; if (!$this->valid && $this->elementsInterator) { $this->elementsInterator = null; } elseif ($this->valid) { ++$this->current; } else { return $this->_next($cssSelector); } }