diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b0e4f6a..1231aa2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3,7 +3,9 @@ name: CI
on:
push:
branches:
- - 2.x
+ - '[0-9]+.x'
+ - '[0-9]+.[0-9]+'
+ - '[0-9]+.[0-9]+.x'
pull_request:
jobs:
@@ -91,7 +93,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: 7.4
+ php-version: 8.3
tools: composer
coverage: xdebug
diff --git a/composer.json b/composer.json
index 11542e4..466c3b9 100644
--- a/composer.json
+++ b/composer.json
@@ -9,17 +9,17 @@
}
],
"require": {
- "php": "^7.2 || ^8.0",
- "nyholm/psr7": "^1.3",
- "php-http/httplug": "^2.0",
+ "php": "^8.1",
+ "nyholm/psr7": "^1.8.1",
+ "php-http/httplug": "^2.4",
"psr/http-client": "^1.0",
"symfony/options-resolver": "^2.6 || ^3.4 || ^4.4 || ^5.0 || ^6.0 || ^7.0"
},
"require-dev": {
- "friendsofphp/php-cs-fixer": "^2.2 || ^3.0",
+ "friendsofphp/php-cs-fixer": "^3.51",
"php-http/client-integration-tests": "^3.0",
- "php-http/message": "^1.9",
- "php-http/client-common": "^2.3",
+ "php-http/message": "^1.16",
+ "php-http/client-common": "^2.7",
"phpunit/phpunit": "^8.5.23 || ~9.5"
},
"provide": {
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 034d22e..f12146d 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -8,7 +8,6 @@
tests/
- tests/SocketClientFeatureTest.php
diff --git a/src/ResponseReader.php b/src/ResponseReader.php
index 66431b0..d5beae6 100644
--- a/src/ResponseReader.php
+++ b/src/ResponseReader.php
@@ -4,7 +4,6 @@
use Http\Client\Socket\Exception\BrokenPipeException;
use Http\Client\Socket\Exception\TimeoutException;
-use Http\Message\ResponseFactory;
use Nyholm\Psr7\Response;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
@@ -18,11 +17,6 @@
*/
trait ResponseReader
{
- /**
- * @var ResponseFactory For creating response
- */
- protected $responseFactory;
-
/**
* Read a response from a socket.
*
diff --git a/src/Stream.php b/src/Stream.php
index 8d26ca0..0c059ca 100644
--- a/src/Stream.php
+++ b/src/Stream.php
@@ -61,7 +61,7 @@ public function __construct(RequestInterface $request, $socket, ?int $size = nul
$this->request = $request;
}
- public function __toString()
+ public function __toString(): string
{
try {
return $this->getContents();
@@ -70,7 +70,7 @@ public function __toString()
}
}
- public function close()
+ public function close(): void
{
if ($this->isDetached || null === $this->socket) {
throw new StreamException('Stream is detached');
@@ -93,12 +93,12 @@ public function detach()
/**
* @return int<0, max>|null
*/
- public function getSize()
+ public function getSize(): ?int
{
return $this->size;
}
- public function tell()
+ public function tell(): int
{
if ($this->isDetached || null === $this->socket) {
throw new StreamException('Stream is detached');
@@ -111,7 +111,7 @@ public function tell()
return $tell;
}
- public function eof()
+ public function eof(): bool
{
if ($this->isDetached || null === $this->socket) {
throw new StreamException('Stream is detached');
@@ -120,38 +120,32 @@ public function eof()
return feof($this->socket);
}
- public function isSeekable()
+ public function isSeekable(): bool
{
return false;
}
- /**
- * @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');
}
- /**
- * @return void
- */
- public function rewind()
+ public function rewind(): void
{
throw new StreamException('This stream is not seekable');
}
- public function isWritable()
+ public function isWritable(): bool
{
return false;
}
- public function write($string)
+ public function write($string): int
{
throw new StreamException('This stream is not writable');
}
- public function isReadable()
+ public function isReadable(): bool
{
return true;
}
@@ -159,7 +153,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');
@@ -197,7 +191,7 @@ public function read($length)
return $read;
}
- public function getContents()
+ public function getContents(): string
{
if ($this->isDetached || null === $this->socket) {
throw new StreamException('Stream is detached');
diff --git a/tests/SocketHttpClientTest.php b/tests/SocketHttpClientTest.php
index c3e5da2..657f2ff 100644
--- a/tests/SocketHttpClientTest.php
+++ b/tests/SocketHttpClientTest.php
@@ -6,15 +6,13 @@
use Http\Client\Socket\Client as SocketHttpClient;
use Http\Client\Socket\Exception\NetworkException;
use Http\Client\Socket\Exception\TimeoutException;
-use Http\Message\MessageFactory\GuzzleMessageFactory;
+use Nyholm\Psr7\Factory\Psr17Factory;
class SocketHttpClientTest extends BaseTestCase
{
public function createClient($options = [])
{
- $messageFactory = new GuzzleMessageFactory();
-
- return new HttpMethodsClient(new SocketHttpClient($options), $messageFactory);
+ return new HttpMethodsClient(new SocketHttpClient($options), new Psr17Factory());
}
public function testTcpSocketDomain()