Skip to content

Commit

Permalink
[BetterPhpDocParser] Simplify BetterTokenIterator (#3656)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Apr 22, 2023
1 parent 731baeb commit 16a20ef
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ final class BetterTokenIterator extends TokenIterator
*/
private const INDEX = 'index';

private readonly PrivatesAccessor $privatesAccessor;

/**
* @param array<int, mixed> $tokens
*/
public function __construct(array $tokens, int $index = 0)
{
$this->privatesAccessor = new PrivatesAccessor();
$privatesAccessor = new PrivatesAccessor();

if ($tokens === []) {
$this->privatesAccessor->setPrivateProperty($this, self::TOKENS, []);
$this->privatesAccessor->setPrivateProperty($this, self::INDEX, 0);
$privatesAccessor->setPrivateProperty($this, self::TOKENS, []);
$privatesAccessor->setPrivateProperty($this, self::INDEX, 0);
} else {
parent::__construct($tokens, $index);
}
Expand Down Expand Up @@ -99,7 +97,7 @@ public function printFromTo(int $from, int $to): string

public function currentPosition(): int
{
return $this->privatesAccessor->getPrivateProperty($this, self::INDEX);
return $this->currentTokenIndex();
}

public function count(): int
Expand Down

0 comments on commit 16a20ef

Please sign in to comment.