Skip to content

Commit

Permalink
Support v2.0 for psr/http-message
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo committed Jun 13, 2023
1 parent a9fa2c7 commit 29e009d
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/Http/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __toString(): string
/**
* Closes the stream and any underlying resources.
*/
public function close()
public function close(): void
{
$this->detach();
}
Expand All @@ -78,7 +78,7 @@ public function detach()
*
* @return null|int returns the size in bytes if known, or null if unknown
*/
public function getSize()
public function getSize(): ?int
{
if (! $this->size) {
$this->size = strlen($this->getContents());
Expand All @@ -92,7 +92,7 @@ public function getSize()
* @return int Position of the file pointer
* @throws RuntimeException on error
*/
public function tell()
public function tell(): int
{
throw new RuntimeException('Cannot determine the position of a SwooleStream');
}
Expand All @@ -102,7 +102,7 @@ public function tell()
*
* @return bool
*/
public function eof()
public function eof(): bool
{
return $this->getSize() === 0;
}
Expand All @@ -112,7 +112,7 @@ public function eof()
*
* @return bool
*/
public function isSeekable()
public function isSeekable(): bool
{
return false;
}
Expand All @@ -129,7 +129,7 @@ public function isSeekable()
* SEEK_END: Set position to end-of-stream plus offset.
* @throws RuntimeException on failure
*/
public function seek($offset, $whence = SEEK_SET)
public function seek($offset, $whence = SEEK_SET): void
{
throw new RuntimeException('Cannot seek a SwooleStream');
}
Expand All @@ -139,11 +139,11 @@ public function seek($offset, $whence = SEEK_SET)
* If the stream is not seekable, this method will raise an exception;
* otherwise, it will perform a seek(0).
*
* @see seek()
* @see http://www.php.net/manual/en/function.fseek.php
* @throws RuntimeException on failure
* @see http://www.php.net/manual/en/function.fseek.php
* @see seek()
*/
public function rewind()
public function rewind(): void
{
$this->seek(0);
}
Expand All @@ -153,7 +153,7 @@ public function rewind()
*
* @return bool
*/
public function isWritable()
public function isWritable(): bool
{
return $this->writable;
}
Expand All @@ -165,7 +165,7 @@ public function isWritable()
* @return int returns the number of bytes written to the stream
* @throws RuntimeException on failure
*/
public function write($string)
public function write($string): int
{
if (! $this->writable) {
throw new RuntimeException('Cannot write to a non-writable stream');
Expand All @@ -184,7 +184,7 @@ public function write($string)
*
* @return bool
*/
public function isReadable()
public function isReadable(): bool
{
return true;
}
Expand All @@ -199,7 +199,7 @@ public function isReadable()
* if no bytes are available
* @throws RuntimeException if an error occurs
*/
public function read($length)
public function read($length): string
{
if ($length >= $this->getSize()) {
$result = $this->contents;
Expand All @@ -221,7 +221,7 @@ public function read($length)
* @throws RuntimeException if unable to read or an error occurs while
* reading
*/
public function getContents()
public function getContents(): string
{
return $this->contents;
}
Expand Down

0 comments on commit 29e009d

Please sign in to comment.