Skip to content

Commit 40c95fb

Browse files
committed
Only emit close on close, emit end on EOS, via @clue at #24 (comment)
1 parent d526abf commit 40c95fb

4 files changed

Lines changed: 3 additions & 15 deletions

File tree

src/Stream/GenericStreamTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public function close()
9393
}
9494

9595
$this->closed = true;
96-
$this->emit('end', [$this]);
9796

9897
$this->filesystem->close($this->fileDescriptor)->then(function () {
9998
$this->emit('close', [$this]);

src/Stream/ReadableStreamTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ protected function performRead($chunkSize)
9999
if ($this->readCursor < $this->size) {
100100
$this->readChunk();
101101
} else {
102+
$this->emit('end', [$this]);
102103
$this->close();
103104
}
104105
});

tests/Stream/ReadableStreamTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,11 @@ public function testClose($className, $stat)
137137
$stream
138138
->expects($this->at(0))
139139
->method('emit')
140-
->with('end', [$stream])
141-
;
142-
143-
$stream
144-
->expects($this->at(1))
145-
->method('emit')
146140
->with('close', [$stream])
147141
;
148142

149143
$stream
150-
->expects($this->at(2))
144+
->expects($this->at(1))
151145
->method('removeAllListeners')
152146
->with()
153147
;

tests/Stream/WritableStreamTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,11 @@ public function testClose($className)
194194
$stream
195195
->expects($this->at(0))
196196
->method('emit')
197-
->with('end', [$stream])
198-
;
199-
200-
$stream
201-
->expects($this->at(1))
202-
->method('emit')
203197
->with('close', [$stream])
204198
;
205199

206200
$stream
207-
->expects($this->at(2))
201+
->expects($this->at(1))
208202
->method('removeAllListeners')
209203
->with()
210204
;

0 commit comments

Comments
 (0)