Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to new Psr\Http\Message\StreamInterface spec #15

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2, 7.1]
php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2]
stability: [prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ composer require zbateson/stream-decorators

## Requirements

StreamDecorators requires PHP 7.1 or newer. Tested on PHP 7.1, 7.2, 7.3, 7.4, 8.0, 8.1 and 8.2.
StreamDecorators requires PHP 7.2 or newer. Tested on PHP 7.2, 7.3, 7.4, 8.0, 8.1 and 8.2.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
],
"require": {
"php": ">=7.1",
"php": ">=7.2",
"guzzlehttp/psr7": "^1.9 | ^2.0",
"zbateson/mb-wrapper": "^1.0.0"
},
Expand Down
11 changes: 2 additions & 9 deletions src/Base64Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,9 @@ public function getSize() : ?int
/**
* Not implemented (yet).
*
* Seek position can be calculated.
*
* @param int $offset
* @param int $whence
* @throws RuntimeException
*/
public function seek($offset, $whence = SEEK_SET)
public function seek(int $offset, int $whence = SEEK_SET) : void
{
throw new RuntimeException('Cannot seek a Base64Stream');
}
Expand Down Expand Up @@ -144,11 +140,8 @@ private function fillBuffer(int $length) : void
*
* Note that reading and writing to the same stream may result in wrongly
* encoded data and is not supported.
*
* @param int $length
* @return string
*/
public function read($length)
public function read(int $length) : string
{
// let Guzzle decide what to do.
if ($length <= 0 || $this->eof()) {
Expand Down
9 changes: 2 additions & 7 deletions src/CharsetStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ public function getSize() : ?int
/**
* Not supported.
*
* @param int $offset
* @param int $whence
* @throws RuntimeException
*/
public function seek($offset, $whence = SEEK_SET)
public function seek(int $offset, int $whence = SEEK_SET) : void
{
throw new RuntimeException('Cannot seek a CharsetStream');
}
Expand Down Expand Up @@ -142,11 +140,8 @@ public function eof() : bool
/**
* Reads up to $length decoded chars from the underlying stream and returns
* them after converting to the target string charset.
*
* @param int $length
* @return string
*/
public function read($length)
public function read(int $length) : string
{
// let Guzzle decide what to do.
if ($length <= 0 || $this->eof()) {
Expand Down
9 changes: 2 additions & 7 deletions src/PregReplaceFilterStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ public function eof() : bool
/**
* Not supported by PregReplaceFilterStream
*
* @param int $offset
* @param int $whence
* @throws RuntimeException
*/
public function seek($offset, $whence = SEEK_SET)
public function seek(int $offset, int $whence = SEEK_SET) : void
{
throw new RuntimeException('Cannot seek a PregReplaceFilterStream');
}
Expand Down Expand Up @@ -99,11 +97,8 @@ private function fillBuffer(int $length) : void
/**
* Reads from the underlying stream, filters it and returns up to $length
* bytes.
*
* @param int $length
* @return string
*/
public function read($length)
public function read(int $length) : string
{
$this->fillBuffer($length);
return $this->buffer->read($length);
Expand Down
6 changes: 1 addition & 5 deletions src/QuotedPrintableStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ public function getSize() : ?int
/**
* Not supported.
*
* @param int $offset
* @param int $whence
* @throws RuntimeException
*/
public function seek($offset, $whence = SEEK_SET)
public function seek(int $offset, int $whence = SEEK_SET) : void
{
throw new RuntimeException('Cannot seek a QuotedPrintableStream');
}
Expand Down Expand Up @@ -138,8 +136,6 @@ private function readRawDecodeAndAppend(int $length, string &$str) : int
/**
* Reads up to $length decoded bytes from the underlying quoted-printable
* encoded stream and returns them.
*
* @param int $length
*/
public function read($length) : string
{
Expand Down
10 changes: 2 additions & 8 deletions src/SeekingLimitStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,8 @@ private function doSeek(int $pos) : void
* For SeekingLimitStream, no actual seek is performed on the underlying
* wrapped stream. Instead, an internal pointer is set, and the stream is
* 'seeked' on read operations
*
* @param int $offset
* @param int $whence
*/
public function seek($offset, $whence = SEEK_SET)
public function seek(int $offset, int $whence = SEEK_SET) : void
{
$pos = $offset;
switch ($whence) {
Expand Down Expand Up @@ -176,11 +173,8 @@ public function seekAndRead(int $length) : string
* Reads from the underlying stream after seeking to the position within the
* bounds set for this limited stream. After reading, the wrapped stream is
* 'seeked' back to its position prior to the call to read().
*
* @param int $length
* @return string
*/
public function read($length)
public function read(int $length) : string
{
$pos = $this->stream->tell();
$ret = $this->seekAndRead($length);
Expand Down
6 changes: 1 addition & 5 deletions src/UUStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ public function getSize() : ?int
/**
* Not supported.
*
* @param int $offset
* @param int $whence
* @throws RuntimeException
*/
public function seek($offset, $whence = SEEK_SET)
public function seek(int $offset, int $whence = SEEK_SET) : void
{
throw new RuntimeException('Cannot seek a UUStream');
}
Expand Down Expand Up @@ -173,8 +171,6 @@ public function eof() : bool

/**
* Attempts to read $length bytes after decoding them, and returns them.
*
* @param int $length
*/
public function read($length) : string
{
Expand Down