Skip to content

Remove BetterTokenIterator - #8856

Merged
TomasVotruba merged 1 commit into
rectorphp:mainfrom
ondrejmirtes:remove-better-token-iterator-duplicates
Oct 27, 2026
Merged

TomasVotruba merged 1 commit into
rectorphp:mainfrom
ondrejmirtes:remove-better-token-iterator-duplicates

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Contributor

This PR removes BetterTokenIterator. Rector now uses TokenIterator from phpstan/phpdoc-parser.

BetterTokenIterator Replacement
currentPosition() TokenIterator::currentTokenIndex()
count() TokenIterator::getTokenCount()
printFromTo() TokenIterator::getContentBetween()
partialTokens(), isTokenTypeOnPosition(), containsTokenType() inline code at the only caller
isNextTokenType(), isNextTokenTypes() NextTokenType::is(), used only by the Doctrine annotation parser

TokenIteratorFactory::createFromTokenIterator() is also removed. It converted a TokenIterator to a BetterTokenIterator.

Use TokenIterator from phpstan/phpdoc-parser:
currentTokenIndex(), getTokenCount() and getContentBetween()
replace currentPosition(), count() and printFromTo().

Only the Doctrine annotation parser checks the type of the next
token. This check is now in NextTokenType.

Amp-Thread-ID: https://ampcode.com/threads/T-01a17930-0285-73c5-a957-4325c77aa1b2
@TomasVotruba
TomasVotruba merged commit 0add245 into rectorphp:main Oct 27, 2026
50 checks passed
@TomasVotruba

Copy link
Copy Markdown
Member

Let's ship it 👍 Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants