You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @klkvsk!
Using json-decode-stream with PHP8, i have some deprecated warning about return type.
Deprecated: Return type of JsonDecodeStream\Internal\SourceBuffer::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \composer\vendor\klkvsk\json-decode-stream\src\Internal\SourceBuffer.php on line 37
Deprecated: Return type of JsonDecodeStream\Internal\SourceBuffer::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \composer\vendor\klkvsk\json-decode-stream\src\Internal\SourceBuffer.php on line 46
Deprecated: Return type of JsonDecodeStream\Internal\SourceBuffer::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \composer\vendor\klkvsk\json-decode-stream\src\Internal\SourceBuffer.php on line 57
Deprecated: Return type of JsonDecodeStream\Internal\SourceBuffer::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \composer\vendor\klkvsk\json-decode-stream\src\Internal\SourceBuffer.php on line 62
Deprecated: Return type of JsonDecodeStream\Internal\SourceBuffer::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \composer\vendor\klkvsk\json-decode-stream\src\Internal\SourceBuffer.php on line 68
Deprecated: Return type of JsonDecodeStream\Tokenizer::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \composer\vendor\klkvsk\json-decode-stream\src\Tokenizer.php on line 39
Here is my patch to correct them (for my usecase only)
not sure for /src/Tokenizer.php l.39 that's the best way to do...
diff --git a/src/Internal/SourceBuffer.php b/src/Internal/SourceBuffer.php
index bad5a98..60d2428 100644
--- a/src/Internal/SourceBuffer.php+++ b/src/Internal/SourceBuffer.php@@ -34,7 +34,7 @@ class SourceBuffer implements Iterator
}
}
- public function current()+ public function current(): mixed
{
if (!$this->valid()) {
return null;
@@ -43,7 +43,7 @@ class SourceBuffer implements Iterator
return $this->buffer[$this->bufferPosition];
}
- public function next()+ public function next(): void
{
$this->bufferPosition++;
if ($this->bufferPosition == min($this->bufferMaxSize, $this->bufferSize)) {
@@ -54,18 +54,18 @@ class SourceBuffer implements Iterator
}
}
- public function key()+ public function key(): mixed
{
return $this->sourcePosition;
}
- public function valid()+ public function valid(): bool
{
return $this->buffer !== null
&& $this->bufferPosition < $this->bufferSize;
}
- public function rewind()+ public function rewind(): void
{
$this->source->rewind();
$this->nextBuffer();
diff --git a/src/Tokenizer.php b/src/Tokenizer.php
index ea2543b..f7614a2 100644
--- a/src/Tokenizer.php+++ b/src/Tokenizer.php@@ -36,7 +36,7 @@ class Tokenizer implements IteratorAggregate
* @psalm-return \Traversable<Token>
* @throws TokenizerException
*/
- public function getIterator()+ public function getIterator(): Generator
{
return $this->tokens();
}
The text was updated successfully, but these errors were encountered:
Hi @klkvsk!
Using json-decode-stream with PHP8, i have some deprecated warning about return type.
Here is my patch to correct them (for my usecase only)
not sure for /src/Tokenizer.php l.39 that's the best way to do...
The text was updated successfully, but these errors were encountered: