diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7df0721..c92fc1c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] + php: [ '8.1', '8.2', '8.3', '8.4' ] os: [ ubuntu-latest, macos-latest, windows-latest ] stability: [ prefer-lowest, prefer-stable ] steps: diff --git a/composer.json b/composer.json index bde465d..066bfb0 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "php": "^8.1", "ext-spl": "*", - "phplrt/lexer": "^4.0" + "phplrt/lexer": "^3.7" }, "autoload": { "psr-4": { @@ -38,8 +38,8 @@ }, "extra": { "branch-alias": { - "dev-master": "4.x-dev", - "dev-main": "4.x-dev" + "dev-master": "3.x-dev", + "dev-main": "3.x-dev" } }, "config": { diff --git a/src/ArrayBuffer.php b/src/ArrayBuffer.php index 244335a..91d2b53 100644 --- a/src/ArrayBuffer.php +++ b/src/ArrayBuffer.php @@ -45,7 +45,7 @@ private function iterableToArray(iterable $tokens): array return $tokens; } - public function seek(mixed $offset): void + public function seek($offset): void { if ($offset < $this->initial) { throw new \OutOfRangeException( diff --git a/src/Buffer.php b/src/Buffer.php index 411b254..ece21f7 100644 --- a/src/Buffer.php +++ b/src/Buffer.php @@ -51,7 +51,7 @@ public function rewind(): void $this->seek($this->initial); } - public function seek(mixed $offset): void + public function seek($offset): void { \assert($offset >= 0); diff --git a/src/BufferInterface.php b/src/BufferInterface.php index a8977a0..c69ebba 100644 --- a/src/BufferInterface.php +++ b/src/BufferInterface.php @@ -20,7 +20,7 @@ interface BufferInterface extends \SeekableIterator * * @param int<0, max> $offset */ - public function seek(mixed $offset): void; + public function seek($offset): void; /** * Return the current token. diff --git a/src/ExtrusiveBuffer.php b/src/ExtrusiveBuffer.php index 40a8927..5e96eab 100644 --- a/src/ExtrusiveBuffer.php +++ b/src/ExtrusiveBuffer.php @@ -20,16 +20,23 @@ class ExtrusiveBuffer extends LazyBuffer */ public const BUFFER_DEFAULT_SIZE = 100; + /** + * @var int<1, max> + */ + private int $size; + /** * @param iterable $stream * @param int<1, max> $size */ public function __construct( iterable $stream, - private int $size = self::BUFFER_DEFAULT_SIZE + int $size = self::BUFFER_DEFAULT_SIZE ) { + $this->size = $size; + /** @psalm-suppress RedundantCondition */ - assert($this->size > 0, 'Buffer size must be greater than 0, but ' . $this->size . ' passed'); + assert($this->size > 0, 'Buffer size must be greater than 0, but ' . $size . ' passed'); parent::__construct($stream); } @@ -42,7 +49,7 @@ public function getBufferSize(): int return $this->size; } - public function seek(mixed $offset): void + public function seek($offset): void { if ($offset < \array_key_first($this->buffer)) { $message = \sprintf(self::ERROR_BUFFER_MEMORY_ALREADY_FREED, $offset, $this->size); diff --git a/src/LazyBuffer.php b/src/LazyBuffer.php index 5d20c6b..9c5ac3f 100644 --- a/src/LazyBuffer.php +++ b/src/LazyBuffer.php @@ -54,7 +54,7 @@ public function getBufferCurrentSize(): int return \count($this->buffer); } - public function seek(mixed $offset): void + public function seek($offset): void { if ($offset < $this->initial) { throw new \OutOfRangeException( diff --git a/src/MutableBuffer.php b/src/MutableBuffer.php index e6dc2f3..0de7d9f 100644 --- a/src/MutableBuffer.php +++ b/src/MutableBuffer.php @@ -10,14 +10,17 @@ */ class MutableBuffer implements BufferInterface { + private BufferInterface $parent; + /** * @var array, TokenInterface> */ private array $overrides = []; - public function __construct( - private BufferInterface $parent, - ) {} + public function __construct(BufferInterface $parent) + { + $this->parent = $parent; + } /** * @param int<0, max> $offset @@ -51,7 +54,7 @@ private function poll(int $offset): TokenInterface } } - public function seek(mixed $offset): void + public function seek($offset): void { $this->parent->seek($offset); }