/** * {@override} */ protected function reset(Tokens $tokens) { $this->current = null; $this->result = array(); $this->stack = array(); $this->tokens = $tokens; $tokens->rewind(); }
/** * @depends testNext */ public function testValid() { $this->tokens->next(); $this->assertTrue($this->tokens->valid()); $this->tokens->next(); $this->assertFalse($this->tokens->valid()); }
/** * {@inheritDoc} * * @throws Exception * @throws UnexpectedTokenException If the token is not expected. */ public function current() { $token = parent::current(); $offset = $this->key(); $before = isset($this[$offset - 1]) ? $this[$offset - 1] : null; // is it an unused token? if (false === self::$sequences[$token[0]]) { throw UnexpectedTokenException::create('Token #%d (%d) is not used by this library.', $offset, $token[0]); // not in the list of expected tokens? } elseif (empty($before) && DocLexer::T_AT !== $token[0] || $before && !isset(self::$sequences[$token[0]][$before[0]])) { throw UnexpectedTokenException::create('Token #%d (%d) is not expected here.', $offset, $token[0]); // before token has another before requirement? } elseif (isset(self::$sequences[$token[0]][$before[0]]) && true !== self::$sequences[$token[0]][$before[0]]) { $ancestor = isset($this[$offset - 2]) ? $this[$offset - 2] : null; if (!$ancestor || $ancestor[0] !== self::$sequences[$token[0]][$before[0]]) { throw UnexpectedTokenException::create('Token #%d (%d) is not expected here.', $offset, $token[0]); } } return $token; }
/** * {@inheritDoc} */ protected function reset(Tokens $tokens) { $this->level = 0; $this->result = ''; $this->tokens = $tokens; $tokens->rewind(); }