1 | <?php |
||
27 | class Client implements HttpClient, HttpAsyncClient |
||
28 | { |
||
29 | /** |
||
30 | * React HTTP client. |
||
31 | * |
||
32 | * @var Client |
||
33 | */ |
||
34 | private $client; |
||
35 | |||
36 | /** |
||
37 | * React event loop. |
||
38 | * |
||
39 | * @var LoopInterface |
||
40 | */ |
||
41 | private $loop; |
||
42 | |||
43 | /** |
||
44 | * @var ResponseFactory |
||
45 | */ |
||
46 | private $responseFactory; |
||
47 | |||
48 | /** |
||
49 | * @var StreamFactory |
||
50 | */ |
||
51 | private $streamFactory; |
||
52 | |||
53 | /** |
||
54 | * Initialize the React client. |
||
55 | * |
||
56 | * @param ResponseFactory|null $responseFactory |
||
57 | * @param LoopInterface|null $loop |
||
58 | * @param ReactClient|null $client |
||
59 | * @param StreamFactory|null $streamFactory |
||
60 | */ |
||
61 | 108 | public function __construct( |
|
62 | 1 | ResponseFactory $responseFactory = null, |
|
63 | LoopInterface $loop = null, |
||
64 | ReactClient $client = null, |
||
65 | StreamFactory $streamFactory = null |
||
66 | ) { |
||
67 | 108 | if (null !== $client && null === $loop) { |
|
68 | throw new \RuntimeException( |
||
69 | 'You must give a LoopInterface instance with the Client' |
||
70 | ); |
||
71 | } |
||
72 | |||
73 | 108 | $this->loop = $loop ?: ReactFactory::buildEventLoop(); |
|
74 | 108 | $this->client = $client ?: ReactFactory::buildHttpClient($this->loop); |
|
|
|||
75 | |||
76 | 108 | $this->responseFactory = $responseFactory ?: MessageFactoryDiscovery::find(); |
|
77 | 108 | $this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find(); |
|
78 | 108 | } |
|
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | 53 | public function sendRequest(RequestInterface $request) |
|
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | 108 | public function sendAsyncRequest(RequestInterface $request) |
|
134 | |||
135 | /** |
||
136 | * Build a React request from the PSR7 RequestInterface. |
||
137 | * |
||
138 | * @param RequestInterface $request |
||
139 | * |
||
140 | * @return ReactRequest |
||
141 | */ |
||
142 | 108 | private function buildReactRequest(RequestInterface $request) |
|
159 | |||
160 | /** |
||
161 | * Transform a React Response to a valid PSR7 ResponseInterface instance. |
||
162 | * |
||
163 | * @param ReactResponse $response |
||
164 | * @param StreamInterface $body |
||
165 | * |
||
166 | * @return ResponseInterface |
||
167 | */ |
||
168 | 105 | private function buildResponse( |
|
182 | } |
||
183 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..