mirror of
https://github.com/danog/phpdoc-parser.git
synced 2025-01-22 22:01:36 +01:00
TokenIterator: add save points
This commit is contained in:
parent
9983296e35
commit
3dda8122e1
@ -13,6 +13,9 @@ class TokenIterator
|
||||
/** @var int */
|
||||
private $index;
|
||||
|
||||
/** @var int[] */
|
||||
private $savePoints = [];
|
||||
|
||||
|
||||
public function __construct(array $tokens, int $index = 0)
|
||||
{
|
||||
@ -147,6 +150,24 @@ class TokenIterator
|
||||
}
|
||||
|
||||
|
||||
public function pushSavePoint(): void
|
||||
{
|
||||
$this->savePoints[] = $this->index;
|
||||
}
|
||||
|
||||
|
||||
public function dropSavePoint(): void
|
||||
{
|
||||
array_pop($this->savePoints);
|
||||
}
|
||||
|
||||
|
||||
public function rollback(): void
|
||||
{
|
||||
$this->index = array_pop($this->savePoints);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws ParserException
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user