Skip to content

Commit

Permalink
Fix rector deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Sep 10, 2024
1 parent c51552c commit 982c655
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": "^8.1",
"ext-spl": "*",
"phplrt/lexer": "^4.0"
"phplrt/lexer": "^3.7"
},
"autoload": {
"psr-4": {
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/Buffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/BufferInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 10 additions & 3 deletions src/ExtrusiveBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,23 @@ class ExtrusiveBuffer extends LazyBuffer
*/
public const BUFFER_DEFAULT_SIZE = 100;

/**
* @var int<1, max>
*/
private int $size;

/**
* @param iterable<TokenInterface> $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);
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/LazyBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 7 additions & 4 deletions src/MutableBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
*/
class MutableBuffer implements BufferInterface
{
private BufferInterface $parent;

/**
* @var array<int<0, max>, TokenInterface>
*/
private array $overrides = [];

public function __construct(
private BufferInterface $parent,
) {}
public function __construct(BufferInterface $parent)
{
$this->parent = $parent;
}

/**
* @param int<0, max> $offset
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 982c655

Please sign in to comment.