File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77final class CompositeStream extends EventEmitter implements DuplexStreamInterface
88{
9- protected $ readable ;
10- protected $ writable ;
11- protected $ closed = false ;
9+ private $ readable ;
10+ private $ writable ;
11+ private $ closed = false ;
1212
1313 public function __construct (ReadableStreamInterface $ readable , WritableStreamInterface $ writable )
1414 {
@@ -77,5 +77,6 @@ public function close()
7777 $ this ->writable ->close ();
7878
7979 $ this ->emit ('close ' );
80+ $ this ->removeAllListeners ();
8081 }
8182}
Original file line number Diff line number Diff line change @@ -92,15 +92,9 @@ public function close()
9292 $ this ->writable = false ;
9393 $ this ->data = '' ;
9494
95- $ this ->emit ('close ' , array ( $ this ) );
95+ $ this ->emit ('close ' );
9696 $ this ->removeAllListeners ();
9797
98- $ this ->handleClose ();
99- }
100-
101- /** @internal */
102- public function handleClose ()
103- {
10498 if (is_resource ($ this ->stream )) {
10599 fclose ($ this ->stream );
106100 }
Original file line number Diff line number Diff line change @@ -188,6 +188,25 @@ public function itShouldForwardCloseOnlyOnce()
188188 $ writable ->close ();
189189 }
190190
191+ /** @test */
192+ public function itShouldForwardCloseAndRemoveAllListeners ()
193+ {
194+ $ in = new ThroughStream ();
195+
196+ $ composite = new CompositeStream ($ in , $ in );
197+ $ composite ->on ('close ' , $ this ->expectCallableOnce ());
198+
199+ $ this ->assertTrue ($ composite ->isReadable ());
200+ $ this ->assertTrue ($ composite ->isWritable ());
201+ $ this ->assertCount (1 , $ composite ->listeners ('close ' ));
202+
203+ $ composite ->close ();
204+
205+ $ this ->assertFalse ($ composite ->isReadable ());
206+ $ this ->assertFalse ($ composite ->isWritable ());
207+ $ this ->assertCount (0 , $ composite ->listeners ('close ' ));
208+ }
209+
191210 /** @test */
192211 public function itShouldReceiveForwardedEvents ()
193212 {
You can’t perform that action at this time.
0 commit comments