@@ -40,6 +40,77 @@ public function testStreamSelectTimeoutEmulation()
4040 $ this ->assertGreaterThan (0.04 , $ interval );
4141 }
4242
43+ public function testStreamSelectReportsWarningForStreamWithFilter ()
44+ {
45+ $ stream = tmpfile ();
46+ stream_filter_append ($ stream , 'string.rot13 ' );
47+
48+ $ this ->loop ->addReadStream ($ stream , $ this ->expectCallableNever ());
49+
50+ $ loop = $ this ->loop ;
51+ $ this ->loop ->futureTick (function () use ($ loop , $ stream ) {
52+ $ loop ->futureTick (function () use ($ loop , $ stream ) {
53+ $ loop ->removeReadStream ($ stream );
54+ });
55+ });
56+
57+ $ error = null ;
58+ $ previous = set_error_handler (function ($ _ , $ errstr ) use (&$ error ) {
59+ $ error = $ errstr ;
60+ });
61+
62+ try {
63+ $ this ->loop ->run ();
64+ } catch (\ValueError $ e ) {
65+ // ignore ValueError for PHP 8+ due to empty stream array
66+ }
67+
68+ restore_error_handler ();
69+
70+ $ this ->assertNotNull ($ error );
71+
72+ $ now = set_error_handler (function () { });
73+ restore_error_handler ();
74+ $ this ->assertEquals ($ previous , $ now );
75+ }
76+
77+ public function testStreamSelectThrowsWhenCustomErrorHandlerThrowsForStreamWithFilter ()
78+ {
79+ $ stream = tmpfile ();
80+ stream_filter_append ($ stream , 'string.rot13 ' );
81+
82+ $ this ->loop ->addReadStream ($ stream , $ this ->expectCallableNever ());
83+
84+ $ loop = $ this ->loop ;
85+ $ this ->loop ->futureTick (function () use ($ loop , $ stream ) {
86+ $ loop ->futureTick (function () use ($ loop , $ stream ) {
87+ $ loop ->removeReadStream ($ stream );
88+ });
89+ });
90+
91+ $ previous = set_error_handler (function ($ _ , $ errstr ) {
92+ throw new \RuntimeException ($ errstr );
93+ });
94+
95+ $ e = null ;
96+ try {
97+ $ this ->loop ->run ();
98+ restore_error_handler ();
99+ $ this ->fail ();
100+ } catch (\RuntimeException $ e ) {
101+ restore_error_handler ();
102+ } catch (\ValueError $ e ) {
103+ restore_error_handler (); // PHP 8+
104+ $ e = $ e ->getPrevious ();
105+ }
106+
107+ $ this ->assertInstanceOf ('RuntimeException ' , $ e );
108+
109+ $ now = set_error_handler (function () { });
110+ restore_error_handler ();
111+ $ this ->assertEquals ($ previous , $ now );
112+ }
113+
43114 public function signalProvider ()
44115 {
45116 return array (
0 commit comments