Skip to content

Commit f201956

Browse files
committed
Remove removeStream() method, use removeReadStream/removeWriteStream
1 parent 58e3814 commit f201956

8 files changed

Lines changed: 6 additions & 77 deletions

File tree

README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $loop->addReadStream($server, function ($server) use ($loop) {
4141
$written = fwrite($conn, $data);
4242
if ($written === strlen($data)) {
4343
fclose($conn);
44-
$loop->removeStream($conn);
44+
$loop->removeWriteStream($conn);
4545
} else {
4646
$data = substr($data, $written);
4747
}
@@ -394,14 +394,6 @@ remove the write event listener for the given stream.
394394
Removing a stream from the loop that has already been removed or trying
395395
to remove a stream that was never added or is invalid has no effect.
396396

397-
### removeStream()
398-
399-
The `removeStream(resource $stream): void` method can be used to
400-
remove all listeners for the given stream.
401-
402-
Removing a stream from the loop that has already been removed or trying
403-
to remove a stream that was never added or is invalid has no effect.
404-
405397
## Install
406398

407399
The recommended way to install this library is [through Composer](http://getcomposer.org).

examples/21-http-server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$written = fwrite($conn, $data);
1515
if ($written === strlen($data)) {
1616
fclose($conn);
17-
$loop->removeStream($conn);
17+
$loop->removeWriteStream($conn);
1818
} else {
1919
$data = substr($data, $written);
2020
}

src/ExtEventLoop.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ public function removeWriteStream($stream)
8888
}
8989
}
9090

91-
/**
92-
* {@inheritdoc}
93-
*/
94-
public function removeStream($stream)
91+
private function removeStream($stream)
9592
{
9693
$key = (int) $stream;
9794

src/LibEvLoop.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,6 @@ public function removeWriteStream($stream)
9494
}
9595
}
9696

97-
/**
98-
* {@inheritdoc}
99-
*/
100-
public function removeStream($stream)
101-
{
102-
$this->removeReadStream($stream);
103-
$this->removeWriteStream($stream);
104-
}
105-
10697
/**
10798
* {@inheritdoc}
10899
*/

src/LibEventLoop.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ public function removeWriteStream($stream)
8989
}
9090
}
9191

92-
/**
93-
* {@inheritdoc}
94-
*/
95-
public function removeStream($stream)
92+
private function removeStream($stream)
9693
{
9794
$key = (int) $stream;
9895

src/LoopInterface.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,6 @@ public function removeReadStream($stream);
120120
*/
121121
public function removeWriteStream($stream);
122122

123-
/**
124-
* Remove all listeners for the given stream.
125-
*
126-
* Removing a stream from the loop that has already been removed or trying
127-
* to remove a stream that was never added or is invalid has no effect.
128-
*
129-
* @param resource $stream The PHP stream resource.
130-
*/
131-
public function removeStream($stream);
132-
133123
/**
134124
* Enqueue a callback to be invoked once after the given interval.
135125
*

src/StreamSelectLoop.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ public function removeWriteStream($stream)
8080
);
8181
}
8282

83-
/**
84-
* {@inheritdoc}
85-
*/
86-
public function removeStream($stream)
87-
{
88-
$this->removeReadStream($stream);
89-
$this->removeWriteStream($stream);
90-
}
91-
9283
/**
9384
* {@inheritdoc}
9485
*/

tests/AbstractLoopTest.php

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,6 @@ public function testRemoveWriteStreamAfterWriting()
126126
$this->tickLoop($this->loop);
127127
}
128128

129-
public function testRemoveStreamInstantly()
130-
{
131-
list ($input, $output) = $this->createSocketPair();
132-
133-
$this->loop->addReadStream($input, $this->expectCallableNever());
134-
$this->loop->addWriteStream($input, $this->expectCallableNever());
135-
$this->loop->removeStream($input);
136-
137-
fwrite($output, "bar\n");
138-
$this->tickLoop($this->loop);
139-
}
140-
141129
public function testRemoveStreamForReadOnly()
142130
{
143131
list ($input, $output) = $this->createSocketPair();
@@ -163,30 +151,13 @@ public function testRemoveStreamForWriteOnly()
163151
$this->tickLoop($this->loop);
164152
}
165153

166-
public function testRemoveStream()
167-
{
168-
list ($input, $output) = $this->createSocketPair();
169-
170-
$this->loop->addReadStream($input, $this->expectCallableOnce());
171-
$this->loop->addWriteStream($input, $this->expectCallableOnce());
172-
173-
fwrite($output, "bar\n");
174-
$this->tickLoop($this->loop);
175-
176-
$this->loop->removeStream($input);
177-
178-
fwrite($output, "bar\n");
179-
$this->tickLoop($this->loop);
180-
}
181-
182154
public function testRemoveInvalid()
183155
{
184156
list ($stream) = $this->createSocketPair();
185157

186158
// remove a valid stream from the event loop that was never added in the first place
187159
$this->loop->removeReadStream($stream);
188160
$this->loop->removeWriteStream($stream);
189-
$this->loop->removeStream($stream);
190161
}
191162

192163
/** @test */
@@ -202,7 +173,7 @@ public function runShouldReturnWhenNoMoreFds()
202173

203174
$loop = $this->loop;
204175
$this->loop->addReadStream($input, function ($stream) use ($loop) {
205-
$loop->removeStream($stream);
176+
$loop->removeReadStream($stream);
206177
});
207178

208179
fwrite($output, "foo\n");
@@ -366,7 +337,7 @@ public function testRunWaitsForFutureTickEvents()
366337
$this->loop->addWriteStream(
367338
$stream,
368339
function () use ($stream) {
369-
$this->loop->removeStream($stream);
340+
$this->loop->removeWriteStream($stream);
370341
$this->loop->futureTick(
371342
function () {
372343
echo 'future-tick' . PHP_EOL;

0 commit comments

Comments
 (0)