Skip to content

Commit f20dbd9

Browse files
committed
Use list<T> in ArrayBuffer instead of custom keys (possibly keys duplication fix).
1 parent 1da0e8d commit f20dbd9

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/ArrayBuffer.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class ArrayBuffer extends Buffer
1010
{
1111
/**
12-
* @var array<int<0, max>, TokenInterface>
12+
* @var list<TokenInterface>
1313
*/
1414
private array $buffer = [];
1515

@@ -25,24 +25,20 @@ public function __construct(iterable $stream)
2525
{
2626
$this->buffer = $this->iterableToArray($stream);
2727
$this->size = \count($this->buffer);
28-
29-
if ($this->buffer !== []) {
30-
$this->initial = $this->current = \array_key_first($this->buffer);
31-
}
3228
}
3329

3430
/**
3531
* @param iterable<int<0, max>, TokenInterface> $tokens
3632
*
37-
* @return array<int<0, max>, TokenInterface>
33+
* @return list<TokenInterface>
3834
*/
3935
private function iterableToArray(iterable $tokens): array
4036
{
4137
if ($tokens instanceof \Traversable) {
42-
return \iterator_to_array($tokens);
38+
return \iterator_to_array($tokens, false);
4339
}
4440

45-
return $tokens;
41+
return \array_values($tokens);
4642
}
4743

4844
public function seek(int $offset): void

0 commit comments

Comments
 (0)