Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/3rdparty.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'guzzlehttp/psr7/src/BufferStream.php')
-rw-r--r--guzzlehttp/psr7/src/BufferStream.php49
1 files changed, 28 insertions, 21 deletions
diff --git a/guzzlehttp/psr7/src/BufferStream.php b/guzzlehttp/psr7/src/BufferStream.php
index 783859c1..21be8c0a 100644
--- a/guzzlehttp/psr7/src/BufferStream.php
+++ b/guzzlehttp/psr7/src/BufferStream.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GuzzleHttp\Psr7;
use Psr\Http\Message\StreamInterface;
@@ -11,32 +13,33 @@ use Psr\Http\Message\StreamInterface;
* This stream returns a "hwm" metadata value that tells upstream consumers
* what the configured high water mark of the stream is, or the maximum
* preferred size of the buffer.
- *
- * @final
*/
-class BufferStream implements StreamInterface
+final class BufferStream implements StreamInterface
{
+ /** @var int */
private $hwm;
+
+ /** @var string */
private $buffer = '';
/**
* @param int $hwm High water mark, representing the preferred maximum
* buffer size. If the size of the buffer exceeds the high
* water mark, then calls to write will continue to succeed
- * but will return false to inform writers to slow down
+ * but will return 0 to inform writers to slow down
* until the buffer has been drained by reading from it.
*/
- public function __construct($hwm = 16384)
+ public function __construct(int $hwm = 16384)
{
$this->hwm = $hwm;
}
- public function __toString()
+ public function __toString(): string
{
return $this->getContents();
}
- public function getContents()
+ public function getContents(): string
{
$buffer = $this->buffer;
$this->buffer = '';
@@ -44,7 +47,7 @@ class BufferStream implements StreamInterface
return $buffer;
}
- public function close()
+ public function close(): void
{
$this->buffer = '';
}
@@ -56,42 +59,42 @@ class BufferStream implements StreamInterface
return null;
}
- public function getSize()
+ public function getSize(): ?int
{
return strlen($this->buffer);
}
- public function isReadable()
+ public function isReadable(): bool
{
return true;
}
- public function isWritable()
+ public function isWritable(): bool
{
return true;
}
- public function isSeekable()
+ public function isSeekable(): bool
{
return false;
}
- public function rewind()
+ public function rewind(): void
{
$this->seek(0);
}
- public function seek($offset, $whence = SEEK_SET)
+ public function seek($offset, $whence = SEEK_SET): void
{
throw new \RuntimeException('Cannot seek a BufferStream');
}
- public function eof()
+ public function eof(): bool
{
return strlen($this->buffer) === 0;
}
- public function tell()
+ public function tell(): int
{
throw new \RuntimeException('Cannot determine the position of a BufferStream');
}
@@ -99,7 +102,7 @@ class BufferStream implements StreamInterface
/**
* Reads data from the buffer.
*/
- public function read($length)
+ public function read($length): string
{
$currentLength = strlen($this->buffer);
@@ -119,21 +122,25 @@ class BufferStream implements StreamInterface
/**
* Writes data to the buffer.
*/
- public function write($string)
+ public function write($string): int
{
$this->buffer .= $string;
- // TODO: What should happen here?
if (strlen($this->buffer) >= $this->hwm) {
- return false;
+ return 0;
}
return strlen($string);
}
+ /**
+ * {@inheritdoc}
+ *
+ * @return mixed
+ */
public function getMetadata($key = null)
{
- if ($key == 'hwm') {
+ if ($key === 'hwm') {
return $this->hwm;
}