Skip to content
Open
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: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
needs:
- supported-versions-matrix
strategy:
fail-fast: false
matrix:
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}

Expand Down Expand Up @@ -56,6 +57,7 @@ jobs:
needs:
- supported-versions-matrix
strategy:
fail-fast: false
matrix:
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.51",
"php-http/client-integration-tests": "^3.1.1",
"php-http/client-integration-tests": "dev-cleanup-major",
"php-http/message": "^1.16",
"php-http/client-common": "^2.7",
"phpunit/phpunit": "^8.5.23 || ~9.5",
"phpunit/phpunit": "^10.0 || ^11.0 || ^12.0",
"php-http/message-factory": "^1.1"
},
"provide": {
Expand Down
12 changes: 6 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
use ResponseReader;

/**
* @var array{remote_socket: string|null, timeout: int, stream_context: resource, stream_context_options: array<string, mixed>, stream_context_param: array<string, mixed>, ssl: ?boolean, write_buffer_size: int, ssl_method: int}
* @var array{remote_socket: string|null, timeout: int, stream_context: resource, stream_context_options: array<string, mixed>, stream_context_param: array<string, mixed>, ssl: ?bool, write_buffer_size: int, ssl_method: int}
*/
private $config;

/**
* Constructor.
*
* @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array<string, mixed>, stream_context_param?: array<string, mixed>, ssl?: ?boolean, write_buffer_size?: int, ssl_method?: int}|ResponseFactoryInterface $config1
* @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array<string, mixed>, stream_context_param?: array<string, mixed>, ssl?: ?boolean, write_buffer_size?: int, ssl_method?: int}|null $config2 Mistake when refactoring the constructor from version 1 to version 2 - used as $config if set and $configOrResponseFactory is a response factory instance
* @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array<string, mixed>, stream_context_param?: array<string, mixed>, ssl?: ?boolean, write_buffer_size?: int, ssl_method?: int} $config intended for version 1 BC, used as $config if $config2 is not set and $configOrResponseFactory is a response factory instance
* @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array<string, mixed>, stream_context_param?: array<string, mixed>, ssl?: ?bool, write_buffer_size?: int, ssl_method?: int}|ResponseFactoryInterface $config1
* @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array<string, mixed>, stream_context_param?: array<string, mixed>, ssl?: ?bool, write_buffer_size?: int, ssl_method?: int}|null $config2 Mistake when refactoring the constructor from version 1 to version 2 - used as $config if set and $configOrResponseFactory is a response factory instance
* @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array<string, mixed>, stream_context_param?: array<string, mixed>, ssl?: ?bool, write_buffer_size?: int, ssl_method?: int} $config intended for version 1 BC, used as $config if $config2 is not set and $configOrResponseFactory is a response factory instance
*
* string|null remote_socket Remote entrypoint (can be a tcp or unix domain address)
* int timeout Timeout before canceling request
Expand Down Expand Up @@ -111,10 +111,10 @@

if (false === $socket) {
if (110 === $errNo) {
throw new TimeoutException($errMsg, $request);

Check failure on line 114 in src/Client.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #1 $message of class Http\Client\Socket\Exception\TimeoutException constructor expects string, string|null given.
}

throw new ConnectionException($errMsg, $request);

Check failure on line 117 in src/Client.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #1 $message of class Http\Client\Socket\Exception\ConnectionException constructor expects string, string|null given.
}

stream_set_timeout($socket, (int) floor($this->config['timeout'] / 1000), $this->config['timeout'] % 1000);
Expand All @@ -141,9 +141,9 @@
/**
* Return configuration for the socket client.
*
* @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array<string, mixed>, stream_context_param?: array<string, mixed>, ssl?: ?boolean, write_buffer_size?: int, ssl_method?: int} $config
* @param array{remote_socket?: string|null, timeout?: int, stream_context?: resource, stream_context_options?: array<string, mixed>, stream_context_param?: array<string, mixed>, ssl?: ?bool, write_buffer_size?: int, ssl_method?: int} $config
*
* @return array{remote_socket: string|null, timeout: int, stream_context: resource, stream_context_options: array<string, mixed>, stream_context_param: array<string, mixed>, ssl: ?boolean, write_buffer_size: int, ssl_method: int}
* @return array{remote_socket: string|null, timeout: int, stream_context: resource, stream_context_options: array<string, mixed>, stream_context_param: array<string, mixed>, ssl: ?bool, write_buffer_size: int, ssl_method: int}
*/
protected function configure(array $config = [])
{
Expand Down
7 changes: 4 additions & 3 deletions tests/SocketHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
use Http\Client\Socket\Exception\NetworkException;
use Http\Client\Socket\Exception\TimeoutException;
use Nyholm\Psr7\Factory\Psr17Factory;
use Psr\Http\Message\ResponseInterface;

class SocketHttpClientTest extends BaseTestCase
{
public function createClient($options = [])
public function createClient($options = []): HttpMethodsClient
{
return new HttpMethodsClient(new SocketHttpClient($options), new Psr17Factory());
}

public function testTcpSocketDomain()
public function testTcpSocketDomain(): void
{
$this->startServer('tcp-server');
$client = $this->createClient(['remote_socket' => '127.0.0.1:19999']);
Expand Down Expand Up @@ -73,7 +74,7 @@ public function testSslRemoteInUri(): void
]);
$response = $client->get('/', []);

$this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $response);
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals(200, $response->getStatusCode());
}

Expand Down
Loading