Skip to content

Commit 5e4db5e

Browse files
committed
React: migrate client factory to use PSR-17
1 parent 599f7d6 commit 5e4db5e

File tree

4 files changed

+5
-17
lines changed

4 files changed

+5
-17
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"php-http/guzzle6-adapter": "<1.1",
4646
"php-http/curl-client": "<2.0",
4747
"php-http/socket-client": "<2.0",
48-
"kriswallsmith/buzz": "<0.17"
48+
"kriswallsmith/buzz": "<0.17",
49+
"php-http/react-adapter": "<3.0"
4950
},
5051
"require-dev": {
5152
"guzzlehttp/psr7": "^1.7 || ^2.0",

src/ClientFactory/ReactFactory.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,12 @@
55
namespace Http\HttplugBundle\ClientFactory;
66

77
use Http\Adapter\React\Client;
8-
use Http\Message\MessageFactory;
98

109
/**
1110
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1211
*/
1312
class ReactFactory implements ClientFactory
1413
{
15-
/**
16-
* @var MessageFactory
17-
*/
18-
private $messageFactory;
19-
20-
public function __construct(MessageFactory $messageFactory)
21-
{
22-
$this->messageFactory = $messageFactory;
23-
}
24-
2514
/**
2615
* {@inheritdoc}
2716
*/
@@ -31,6 +20,6 @@ public function createClient(array $config = [])
3120
throw new \LogicException('To use the React adapter you need to install the "php-http/react-adapter" package.');
3221
}
3322

34-
return new Client($this->messageFactory);
23+
return new Client();
3524
}
3625
}

src/Resources/config/services.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@
9191
</service>
9292
<service id="httplug.factory.guzzle6" class="Http\HttplugBundle\ClientFactory\Guzzle6Factory" public="false" />
9393
<service id="httplug.factory.guzzle7" class="Http\HttplugBundle\ClientFactory\Guzzle7Factory" public="false" />
94-
<service id="httplug.factory.react" class="Http\HttplugBundle\ClientFactory\ReactFactory" public="false">
95-
<argument type="service" id="httplug.message_factory"/>
96-
</service>
94+
<service id="httplug.factory.react" class="Http\HttplugBundle\ClientFactory\ReactFactory" public="false" />
9795
<service id="httplug.factory.socket" class="Http\HttplugBundle\ClientFactory\SocketFactory" public="false">
9896
<argument type="service" id="httplug.message_factory"/>
9997
</service>

tests/Unit/ClientFactory/ReactFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testCreateClient(): void
2020
$this->markTestSkipped('React adapter is not installed');
2121
}
2222

23-
$factory = new ReactFactory($this->getMockBuilder(MessageFactory::class)->getMock());
23+
$factory = new ReactFactory();
2424
$client = $factory->createClient();
2525

2626
$this->assertInstanceOf(Client::class, $client);

0 commit comments

Comments
 (0)