2
2
3
3
namespace Http \Adapter \React ;
4
4
5
+ use Http \Discovery \MessageFactoryDiscovery ;
5
6
use Psr \Http \Message \ResponseInterface ;
6
7
use React \EventLoop \LoopInterface ;
7
8
use React \Promise \Deferred ;
@@ -38,7 +39,7 @@ class Client implements HttpClient, HttpAsyncClient
38
39
private $ loop ;
39
40
40
41
/**
41
- * HttpPlug message factory.
42
+ * HTTPlug message factory.
42
43
*
43
44
* @var MessageFactory
44
45
*/
@@ -47,12 +48,12 @@ class Client implements HttpClient, HttpAsyncClient
47
48
/**
48
49
* Initialize the React client.
49
50
*
50
- * @param MessageFactory $messageFactory
51
- * @param LoopInterface|null $loop React Event loop
52
- * @param ReactClient $client React client to use
51
+ * @param MessageFactory|null $messageFactory
52
+ * @param LoopInterface|null $loop React Event loop
53
+ * @param ReactClient|null $client React client to use
53
54
*/
54
55
public function __construct (
55
- MessageFactory $ messageFactory ,
56
+ MessageFactory $ messageFactory = null ,
56
57
LoopInterface $ loop = null ,
57
58
ReactClient $ client = null
58
59
) {
@@ -64,7 +65,7 @@ public function __construct(
64
65
$ this ->loop = (null !== $ loop ) ?: ReactFactory::buildEventLoop ();
65
66
$ this ->client = (null !== $ client ) ?: ReactFactory::buildHttpClient ($ this ->loop );
66
67
67
- $ this ->messageFactory = $ messageFactory ;
68
+ $ this ->messageFactory = $ messageFactory ?: MessageFactoryDiscovery:: find () ;
68
69
}
69
70
70
71
/**
0 commit comments