diff --git a/CHANGELOG.md b/CHANGELOG.md index 0909b69..29b82f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 2.1.2 + + * Fixed the type hinting of Stream class in order to make it compatible with StreamInterface + * Replaced the deprecated interface HttpClient + ## 2.1.1 * Fixed constructor to work nicely with version 1 style arguments (e.g. HttplugBundle) diff --git a/src/Client.php b/src/Client.php index 6f57816..8faa7e3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -2,11 +2,11 @@ namespace Http\Client\Socket; -use Http\Client\HttpClient; use Http\Client\Socket\Exception\ConnectionException; use Http\Client\Socket\Exception\InvalidRequestException; use Http\Client\Socket\Exception\SSLConnectionException; use Http\Client\Socket\Exception\TimeoutException; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; @@ -20,7 +20,7 @@ * * @author Joel Wurtz */ -class Client implements HttpClient +class Client implements ClientInterface { use RequestWriter; use ResponseReader; diff --git a/src/Stream.php b/src/Stream.php index c2475df..f614e3e 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -64,7 +64,7 @@ public function __construct(RequestInterface $request, $socket, ?int $size = nul /** * {@inheritdoc} */ - public function __toString() + public function __toString(): string { try { return $this->getContents(); @@ -76,7 +76,7 @@ public function __toString() /** * {@inheritdoc} */ - public function close() + public function close(): void { if ($this->isDetached || null === $this->socket) { throw new StreamException('Stream is detached'); @@ -104,7 +104,7 @@ public function detach() * * @return int<0, max>|null */ - public function getSize() + public function getSize(): ?int { return $this->size; } @@ -112,7 +112,7 @@ public function getSize() /** * {@inheritdoc} */ - public function tell() + public function tell(): int { if ($this->isDetached || null === $this->socket) { throw new StreamException('Stream is detached'); @@ -128,7 +128,7 @@ public function tell() /** * {@inheritdoc} */ - public function eof() + public function eof(): bool { if ($this->isDetached || null === $this->socket) { throw new StreamException('Stream is detached'); @@ -140,7 +140,7 @@ public function eof() /** * {@inheritdoc} */ - public function isSeekable() + public function isSeekable(): bool { return false; } @@ -150,7 +150,7 @@ public function isSeekable() * * @return void */ - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { throw new StreamException('This stream is not seekable'); } @@ -160,7 +160,7 @@ public function seek($offset, $whence = SEEK_SET) * * @return void */ - public function rewind() + public function rewind(): void { throw new StreamException('This stream is not seekable'); } @@ -168,7 +168,7 @@ public function rewind() /** * {@inheritdoc} */ - public function isWritable() + public function isWritable(): bool { return false; } @@ -176,7 +176,7 @@ public function isWritable() /** * {@inheritdoc} */ - public function write($string) + public function write($string): int { throw new StreamException('This stream is not writable'); } @@ -184,7 +184,7 @@ public function write($string) /** * {@inheritdoc} */ - public function isReadable() + public function isReadable(): bool { return true; } @@ -194,7 +194,7 @@ public function isReadable() * * @param int<0, max> $length */ - public function read($length) + public function read($length): string { if ($this->isDetached || null === $this->socket) { throw new StreamException('Stream is detached'); @@ -235,7 +235,7 @@ public function read($length) /** * {@inheritdoc} */ - public function getContents() + public function getContents(): string { if ($this->isDetached || null === $this->socket) { throw new StreamException('Stream is detached');