Skip to content

Commit f1e457d

Browse files
authored
Merge pull request #62 from clue-labs/close
Rename shutdown() to close() for consistency throughout React
2 parents cf074e5 + 4e30979 commit f1e457d

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ and [`Stream`](https://github.com/reactphp/stream) components.
1717
* [error event](#error-event)
1818
* [listen()](#listen)
1919
* [getPort()](#getport)
20-
* [shutdown()](#shutdown)
20+
* [close()](#close)
2121
* [Server](#server)
2222
* [SecureServer](#secureserver)
2323
* [ConnectionInterface](#connectioninterface)
@@ -146,22 +146,22 @@ echo 'Server listening on port ' . $port . PHP_EOL;
146146
```
147147

148148
This method MUST NOT be called before calling [`listen()`](#listen).
149-
This method MUST NOT be called after calling [`shutdown()`](#shutdown).
149+
This method MUST NOT be called after calling [`close()`](#close).
150150

151-
#### shutdown()
151+
#### close()
152152

153-
The `shutdown(): void` method can be used to
153+
The `close(): void` method can be used to
154154
shut down this listening socket.
155155

156156
This will stop listening for new incoming connections on this socket.
157157

158158
```php
159159
echo 'Shutting down server socket' . PHP_EOL;
160-
$server->shutdown();
160+
$server->close();
161161
```
162162

163163
This method MUST NOT be called before calling [`listen()`](#listen).
164-
This method MUST NOT be called after calling [`shutdown()`](#shutdown).
164+
This method MUST NOT be called after calling [`close()`](#close).
165165

166166
### Server
167167

src/SecureServer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public function getPort()
7878
return $this->tcp->getPort();
7979
}
8080

81-
public function shutdown()
81+
public function close()
8282
{
83-
return $this->tcp->shutdown();
83+
return $this->tcp->close();
8484
}
8585

8686
/** @internal */

src/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function getPort()
120120
return (int) substr(strrchr($name, ':'), 1);
121121
}
122122

123-
public function shutdown()
123+
public function close()
124124
{
125125
$this->loop->removeStream($this->master);
126126
fclose($this->master);

src/ServerInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function listen($port, $host = '127.0.0.1');
7272
* Returns the port this server is currently listening on
7373
*
7474
* This method MUST NOT be called before calling listen().
75-
* This method MUST NOT be called after calling shutdown().
75+
* This method MUST NOT be called after calling close().
7676
*
7777
* @return int the port number
7878
*/
@@ -84,9 +84,9 @@ public function getPort();
8484
* This will stop listening for new incoming connections on this socket.
8585
*
8686
* This method MUST NOT be called before calling listen().
87-
* This method MUST NOT be called after calling shutdown().
87+
* This method MUST NOT be called after calling close().
8888
*
8989
* @return void
9090
*/
91-
public function shutdown();
91+
public function close();
9292
}

tests/SecureServerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ public function testGetPortWillBePassedThroughToTcpServer()
2525
$this->assertEquals(1234, $server->getPort());
2626
}
2727

28-
public function testShutdownWillBePassedThroughToTcpServer()
28+
public function testCloseWillBePassedThroughToTcpServer()
2929
{
3030
$tcp = $this->getMockBuilder('React\Socket\Server')->disableOriginalConstructor()->getMock();
31-
$tcp->expects($this->once())->method('shutdown');
31+
$tcp->expects($this->once())->method('close');
3232

3333
$loop = $this->getMock('React\EventLoop\LoopInterface');
3434

3535
$server = new SecureServer($tcp, $loop, array());
3636

37-
$server->shutdown();
37+
$server->close();
3838
}
3939
}

tests/ServerTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,27 +132,27 @@ public function testDataWillBeFragmentedToBufferSize()
132132
$this->loop->tick();
133133
}
134134

135-
public function testLoopWillEndWhenServerIsShutDown()
135+
public function testLoopWillEndWhenServerIsClosed()
136136
{
137-
// explicitly unset server because we already call shutdown()
138-
$this->server->shutdown();
137+
// explicitly unset server because we already call close()
138+
$this->server->close();
139139
$this->server = null;
140140

141141
$this->loop->run();
142142
}
143143

144-
public function testLoopWillEndWhenServerIsShutDownAfterSingleConnection()
144+
public function testLoopWillEndWhenServerIsClosedAfterSingleConnection()
145145
{
146146
$client = stream_socket_client('tcp://localhost:' . $this->port);
147147

148148
// explicitly unset server because we only accept a single connection
149-
// and then already call shutdown()
149+
// and then already call close()
150150
$server = $this->server;
151151
$this->server = null;
152152

153153
$server->on('connection', function ($conn) use ($server) {
154154
$conn->close();
155-
$server->shutdown();
155+
$server->close();
156156
});
157157

158158
$this->loop->run();
@@ -169,7 +169,7 @@ public function testDataWillBeEmittedInMultipleChunksWhenClientSendsExcessiveAmo
169169
$mock = $this->expectCallableOnce();
170170

171171
// explicitly unset server because we only accept a single connection
172-
// and then already call shutdown()
172+
// and then already call close()
173173
$server = $this->server;
174174
$this->server = null;
175175

@@ -183,7 +183,7 @@ public function testDataWillBeEmittedInMultipleChunksWhenClientSendsExcessiveAmo
183183
$conn->on('end', $mock);
184184

185185
// do not await any further connections in order to let the loop terminate
186-
$server->shutdown();
186+
$server->close();
187187
});
188188

189189
$this->loop->run();
@@ -236,12 +236,12 @@ public function testListenOnBusyPortThrows()
236236
}
237237

238238
/**
239-
* @covers React\Socket\Server::shutdown
239+
* @covers React\Socket\Server::close
240240
*/
241241
public function tearDown()
242242
{
243243
if ($this->server) {
244-
$this->server->shutdown();
244+
$this->server->close();
245245
}
246246
}
247247
}

tests/Stub/ServerStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function getPort()
1616
return 80;
1717
}
1818

19-
public function shutdown()
19+
public function close()
2020
{
2121
}
2222
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy