Skip to content

Commit

Permalink
Add PHP 8.4 (alpha build) tests support
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Jul 28, 2024
1 parent 8961be8 commit f14b223
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/ArrayBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function __construct(iterable $stream)

/**
* @param iterable<int<0, max>, TokenInterface> $tokens
*
* @return array<int<0, max>, TokenInterface>
*/
private function iterableToArray(iterable $tokens): array
Expand Down
1 change: 0 additions & 1 deletion src/Buffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public function seek($offset): void

/**
* @param array<TokenInterface> $data
*
* @psalm-suppress PossiblyNullArrayOffset
*/
protected function currentFrom(array $data): TokenInterface
Expand Down
6 changes: 0 additions & 6 deletions src/BufferInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface BufferInterface extends \SeekableIterator
* Rewind the BufferInterface to the target token element.
*
* @link https://php.net/manual/en/seekableiterator.seek.php
*
* @see \SeekableIterator::seek()
*
* @param int<0, max> $offset
Expand All @@ -26,7 +25,6 @@ public function seek($offset): void;
* Return the current token.
*
* @link https://php.net/manual/en/iterator.current.php
*
* @see \Iterator::current()
*/
public function current(): TokenInterface;
Expand All @@ -35,7 +33,6 @@ public function current(): TokenInterface;
* Return the ordinal id of the current token element.
*
* @link https://php.net/manual/en/iterator.key.php
*
* @see \Iterator::key()
*
* @return int<0, max>
Expand All @@ -46,7 +43,6 @@ public function key(): int;
* Checks if current position is valid and iterator not completed.
*
* @link https://php.net/manual/en/iterator.valid.php
*
* @see \Iterator::valid()
*/
public function valid(): bool;
Expand All @@ -55,7 +51,6 @@ public function valid(): bool;
* Rewind the BufferInterface to the first token element.
*
* @link https://php.net/manual/en/iterator.rewind.php
*
* @see \Iterator::rewind()
*/
public function rewind(): void;
Expand All @@ -64,7 +59,6 @@ public function rewind(): void;
* Move forward to next token element.
*
* @link https://php.net/manual/en/iterator.next.php
*
* @see \Iterator::next()
*/
public function next(): void;
Expand Down
2 changes: 1 addition & 1 deletion src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

final class Factory implements FactoryInterface
{
public function create(iterable $tokens, ?int $size = null): BufferInterface
public function create(iterable $tokens, int $size = null): BufferInterface
{
if ($size === null) {
return new ArrayBuffer($tokens);
Expand Down
2 changes: 1 addition & 1 deletion src/LazyBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function __construct(iterable $stream)

/**
* @param iterable<TokenInterface> $stream
*
* @return \Generator<mixed, TokenInterface, mixed, mixed>
*/
private function toGenerator(iterable $stream): \Generator
Expand Down Expand Up @@ -114,6 +113,7 @@ protected function nextValid(): bool
}

/**
* {@inheritDoc}
* @psalm-suppress MixedReturnTypeCoercion
*/
public function key(): int
Expand Down
14 changes: 6 additions & 8 deletions tests/Unit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ public static function buffersDataProvider(): array
{
return [
'Generator' => [
static::create(self::createTokens(static::$bufferSize)),
static::create(self::createTokens((static::$bufferSize))),
],
'array' => [
static::create([
...self::createTokens(static::$bufferSize),
...self::createTokens((static::$bufferSize)),
]),
],
'IteratorIterator' => [
static::create(new \IteratorIterator(
self::createTokens(static::$bufferSize),
self::createTokens((static::$bufferSize)),
)),
],
'ArrayIterator' => [
static::create(new \ArrayIterator([
...self::createTokens(static::$bufferSize),
...self::createTokens((static::$bufferSize)),
])),
],
];
Expand Down Expand Up @@ -95,8 +95,7 @@ public function testRewindable(BufferInterface $buffer): void
$needle = $buffer->current();

// Iterate
foreach ($buffer as $token) {
}
foreach ($buffer as $token);

$this->assertNotSame($needle, $buffer->current());
$buffer->rewind();
Expand All @@ -114,8 +113,7 @@ public function testSeekAhead(BufferInterface $buffer): void

$buffer->rewind();

foreach ($buffer as $item) {
}
foreach ($buffer as $item);

$this->assertSame($buffer->current(), $needle);
}
Expand Down

0 comments on commit f14b223

Please sign in to comment.