Skip to content

Commit f2bd0d6

Browse files
committed
[SocketClient] Rename Connector::createTcp to Connector::create
1 parent 0f05817 commit f2bd0d6

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

UPGRADE-0.3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ HttpClient
2222
----------
2323

2424
* `HttpClient\*ConnectionManager` has been moved to `SocketClient\*Connector`,
25-
and the `getConnection` method has been renamed to `createTcp`.
25+
and the `getConnection` method has been renamed to `create`.
2626

2727
Before:
2828

2929
$connectionManager->getConnection($host, $port);
3030

3131
After:
3232

33-
$connector->createTcp($host, $port);
33+
$connector->create($host, $port);

src/React/HttpClient/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ protected function connect()
218218
$port = $this->requestData->getPort();
219219

220220
return $this->connector
221-
->createTcp($host, $port);
221+
->create($host, $port);
222222
}
223223

224224
public function setResponseFactory($factory)

src/React/SocketClient/Connector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(LoopInterface $loop, Resolver $resolver)
1919
$this->resolver = $resolver;
2020
}
2121

22-
public function createTcp($host, $port)
22+
public function create($host, $port)
2323
{
2424
$that = $this;
2525

src/React/SocketClient/ConnectorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
interface ConnectorInterface
66
{
7-
public function createTcp($host, $port);
7+
public function create($host, $port);
88
}

src/React/SocketClient/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ $dns = $dnsResolverFactory->createCached('8.8.8.8', $loop);
3434
### Async TCP/IP connections
3535

3636
The `React\SocketClient\Connector` provides a single promise-based
37-
`createTcp($host, $ip)` method which resolves as soon as the connection
37+
`create($host, $ip)` method which resolves as soon as the connection
3838
succeeds or fails.
3939

4040
```php
4141
$connector = new React\SocketClient\Connector($loop, $dns);
4242

43-
$connector->createTcp('www.google.com', 80)->then(function (React\Stream\Stream $stream) {
43+
$connector->create('www.google.com', 80)->then(function (React\Stream\Stream $stream) {
4444
$stream->write('...');
4545
$stream->close();
4646
});
@@ -50,13 +50,13 @@ $connector->createTcp('www.google.com', 80)->then(function (React\Stream\Stream
5050

5151
The `SecureConnector` class decorates a given `Connector` instance by enabling
5252
SSL/TLS encryption as soon as the raw TCP/IP connection succeeds. It provides
53-
the same promise- based `createTcp($host, $ip)` method which resolves with
53+
the same promise- based `create($host, $ip)` method which resolves with
5454
a `Stream` instance that can be used just like any non-encrypted stream.
5555

5656
```php
5757
$secureConnector = new React\SocketClient\SecureConnector($connector, $loop);
5858

59-
$secureConnector->createTcp('www.google.com', 443)->then(function (React\Stream\Stream $stream) {
59+
$secureConnector->create('www.google.com', 443)->then(function (React\Stream\Stream $stream) {
6060
$stream->write("GET / HTTP/1.0\r\nHost: www.google.com\r\n\r\n");
6161
...
6262
});

src/React/SocketClient/SecureConnector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public function __construct(ConnectorInterface $connector, LoopInterface $loop)
1919
$this->streamEncryption = new StreamEncryption($loop);
2020
}
2121

22-
public function createTcp($host, $port)
22+
public function create($host, $port)
2323
{
2424
$streamEncryption = $this->streamEncryption;
25-
return $this->connector->createTcp($host, $port)->then(function (Stream $stream) use ($streamEncryption) {
25+
return $this->connector->create($host, $port)->then(function (Stream $stream) use ($streamEncryption) {
2626
// (unencrypted) connection succeeded => try to enable encryption
2727
return $streamEncryption->enable($stream)->then(null, function ($error) use ($stream) {
2828
// establishing encryption failed => close invalid connection and return error

tests/React/Tests/HttpClient/RequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ private function successfulConnectionMock()
391391
{
392392
$this->connector
393393
->expects($this->once())
394-
->method('createTcp')
394+
->method('create')
395395
->with('www.example.com', 80)
396396
->will($this->returnValue(new FulfilledPromise($this->stream)));
397397
}
@@ -400,7 +400,7 @@ private function rejectedConnectionMock()
400400
{
401401
$this->connector
402402
->expects($this->once())
403-
->method('createTcp')
403+
->method('create')
404404
->with('www.example.com', 80)
405405
->will($this->returnValue(new RejectedPromise(new \RuntimeException())));
406406
}

tests/React/Tests/SocketClient/ConnectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function connectionToEmptyPortShouldFail()
1717
$dns = $this->createResolverMock();
1818

1919
$connector = new Connector($loop, $dns);
20-
$connector->createTcp('127.0.0.1', 9999)
20+
$connector->create('127.0.0.1', 9999)
2121
->then($this->expectCallableNever(), $this->expectCallableOnce());
2222

2323
$loop->run();
@@ -40,7 +40,7 @@ public function connectionToTcpServerShouldSucceed()
4040
$dns = $this->createResolverMock();
4141

4242
$connector = new Connector($loop, $dns);
43-
$connector->createTcp('127.0.0.1', 9999)
43+
$connector->create('127.0.0.1', 9999)
4444
->then(function ($stream) use (&$capturedStream) {
4545
$capturedStream = $stream;
4646
$stream->end();

0 commit comments

Comments
 (0)