REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.73 KB
Close
/opt/cpanel/ea-wappspector/vendor/rector/rector/src/BetterPhpDocParser/ValueObject/Parser/BetterTokenIterator.php
Text
Base64
<?php declare (strict_types=1); namespace Rector\BetterPhpDocParser\ValueObject\Parser; use PHPStan\PhpDocParser\Parser\TokenIterator; use Rector\Exception\ShouldNotHappenException; final class BetterTokenIterator extends TokenIterator { /** * @param array<int, mixed> $tokens */ public function __construct(array $tokens, int $index = 0) { if ($tokens === []) { $index = 0; } parent::__construct($tokens, $index); } /** * @param int[] $types */ public function isNextTokenTypes(array $types) : bool { foreach ($types as $type) { if ($this->isNextTokenType($type)) { return \true; } } return \false; } public function isTokenTypeOnPosition(int $tokenType, int $position) : bool { $tokens = $this->getTokens(); $token = $tokens[$position] ?? null; if ($token === null) { return \false; } return $token[1] === $tokenType; } public function isNextTokenType(int $tokenType) : bool { if ($this->nextTokenType() === null) { return \false; } return $this->nextTokenType() === $tokenType; } public function printFromTo(int $from, int $to) : string { if ($to < $from) { throw new ShouldNotHappenException('Arguments are flipped'); } $tokens = $this->getTokens(); $content = ''; foreach ($tokens as $key => $token) { if ($key < $from) { continue; } if ($key >= $to) { continue; } $content .= $token[0]; } return $content; } public function currentPosition() : int { return $this->currentTokenIndex(); } public function count() : int { return \count($this->getTokens()); } /** * @return array<array{0: string, 1: int}> */ public function partialTokens(int $start, int $end) : array { return \array_slice($this->getTokens(), $start, $end); } public function containsTokenType(int $type) : bool { foreach ($this->getTokens() as $token) { if ($token[1] === $type) { return \true; } } return \false; } private function nextTokenType() : ?int { $tokens = $this->getTokens(); // does next token exist? $nextIndex = $this->currentPosition() + 1; if (!isset($tokens[$nextIndex])) { return null; } $this->pushSavePoint(); $this->next(); $nextTokenType = $this->currentTokenType(); $this->rollback(); return $nextTokenType; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 1
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
BetterTokenIterator.php
2.73 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).