Skip to content

Commit b573b9c

Browse files
qkdreyerdbu
authored andcommitted
fix: allow configuration of php-http/socket-client >=2.0
1 parent 0df8689 commit b573b9c

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 2.0.5 (unreleased)
44

5+
* Fixed constructor to work nicely with version 1 style arguments (e.g. HttplugBundle)
56
* Fixed PHP 8 compatibility for stream timeouts
67
* Renamed `master` branch to `2.x` for semantic branch naming.
78

phpstan.neon.dist

-15
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,6 @@ parameters:
99
count: 1
1010
path: src/RequestWriter.php
1111

12-
-
13-
message: "#^Constructor of class Http\\\\Client\\\\Socket\\\\Client has an unused parameter \\$config2\\.$#"
14-
count: 1
15-
path: src/Client.php
16-
17-
-
18-
message: "#^Method Http\\\\Client\\\\Socket\\\\Client\\:\\:__construct\\(\\) has parameter \\$config1 with no type specified\\.$#"
19-
count: 1
20-
path: src/Client.php
21-
22-
-
23-
message: "#^Method Http\\\\Client\\\\Socket\\\\Client\\:\\:__construct\\(\\) has parameter \\$config2 with no type specified\\.$#"
24-
count: 1
25-
path: src/Client.php
26-
2712
-
2813
message: "#^Method Http\\\\Client\\\\Socket\\\\Client\\:\\:configure\\(\\) should 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\\|null, write_buffer_size\\: int, ssl_method\\: int\\} but returns array\\.$#"
2914
count: 1

src/Client.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Http\Client\Socket\Exception\SSLConnectionException;
99
use Http\Client\Socket\Exception\TimeoutException;
1010
use Psr\Http\Message\RequestInterface;
11+
use Psr\Http\Message\ResponseFactoryInterface;
1112
use Psr\Http\Message\ResponseInterface;
1213
use Symfony\Component\OptionsResolver\Options;
1314
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -32,7 +33,9 @@ class Client implements HttpClient
3233
/**
3334
* Constructor.
3435
*
35-
* @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
36+
* @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
37+
* @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
38+
* @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
3639
*
3740
* string|null remote_socket Remote entrypoint (can be a tcp or unix domain address)
3841
* int timeout Timeout before canceling request
@@ -51,9 +54,9 @@ public function __construct($config1 = [], $config2 = null, array $config = [])
5154
return;
5255
}
5356

54-
@trigger_error('Passing a Psr\Http\Message\ResponseFactoryInterface and a Psr\Http\Message\StreamFactoryInterface to SocketClient is deprecated, and will be removed in 3.0, you should only pass config options.', E_USER_DEPRECATED);
57+
@trigger_error('Passing a Psr\Http\Message\ResponseFactoryInterface to SocketClient is deprecated, and will be removed in 3.0, you should only pass config options.', E_USER_DEPRECATED);
5558

56-
$this->config = $this->configure($config);
59+
$this->config = $this->configure($config2 ?: $config);
5760
}
5861

5962
/**

0 commit comments

Comments
 (0)