@@ -99,7 +99,7 @@ function pt_print_events($watchers, $read_data = false): void {
9999 die ('Invalid event type ' );
100100 }
101101 echo "Event[ $ i]: " . $ watcher ->getTriggeredEvents () . ", user data: " . $ watcher ->getData ();
102- if ($ read_data && $ watcher ->hasTriggered (POLL_READ )) {
102+ if ($ read_data && $ watcher ->hasTriggered (POLL_EVENT_READ )) {
103103 $ data = fread ($ watcher ->getHandle ()->getStream (), 1024 );
104104 echo ", read data: ' $ data' " ;
105105 }
@@ -173,7 +173,7 @@ function pt_expect_events($watchers, $expected, ?PollContext $poll_ctx = null):
173173
174174 // If read data is expected, check it
175175 if (isset ($ exp_event ['read ' ])) {
176- $ read_data = fread ($ watcher [$ act_idx ]->getHandle ()->getStream (), 1024 );
176+ $ read_data = fread ($ watchers [$ act_idx ]->getHandle ()->getStream (), 1024 );
177177 if ($ read_data !== $ exp_event ['read ' ]) {
178178 continue ; // Read data doesn't match
179179 }
@@ -226,34 +226,34 @@ function pt_resolve_backend_specific_value($backend_map, $current_backend) {
226226
227227function pt_event_flags_to_string ($ flags ): string {
228228 $ names = [];
229- if ($ flags & POLL_READ ) $ names [] = 'READ ' ;
230- if ($ flags & POLL_WRITE ) $ names [] = 'WRITE ' ;
231- if ($ flags & POLL_ERROR ) $ names [] = 'ERROR ' ;
232- if ($ flags & POLL_HUP ) $ names [] = 'HUP ' ;
229+ if ($ flags & POLL_EVENT_READ ) $ names [] = 'READ ' ;
230+ if ($ flags & POLL_EVENT_WRITE ) $ names [] = 'WRITE ' ;
231+ if ($ flags & POLL_EVENT_ERROR ) $ names [] = 'ERROR ' ;
232+ if ($ flags & POLL_EVENT_HUP ) $ names [] = 'HUP ' ;
233233
234234 return empty ($ names ) ? 'NONE: ' . $ flags : implode ('| ' , $ names );
235235}
236236
237- function pt_print_mismatched_events ($ actual_events , $ expected_events , $ matched = [], $ backend_name = null ): void {
237+ function pt_print_mismatched_events ($ actual_watchers , $ expected_watchers , $ matched = [], $ backend_name = null ): void {
238238 echo "Actual events: \n" ;
239- foreach ($ actual_events as $ i => $ event ) {
239+ foreach ($ actual_watchers as $ i => $ watcher ) {
240240 $ match_status = isset ($ matched [$ i ]) ? " [MATCHED] " : " [UNMATCHED] " ;
241- $ event_names = pt_event_flags_to_string ($ event -> events );
242- echo " Event[ $ i]: $ event_names , user data: " . $ event -> data . $ match_status . "\n" ;
241+ $ watcher_names = pt_event_flags_to_string ($ watcher -> getTriggeredEvents () );
242+ echo " Event[ $ i]: $ watcher_names , user data: " . $ watcher -> getData () . $ match_status . "\n" ;
243243 }
244244
245245 echo "Expected events: \n" ;
246- foreach ($ expected_events as $ i => $ exp_event ) {
246+ foreach ($ expected_watchers as $ i => $ exp_event ) {
247247 $ was_matched = in_array ($ i , $ matched );
248248 $ match_status = $ was_matched ? " [MATCHED] " : " [UNMATCHED] " ;
249249
250- $ events_value = $ exp_event ['events ' ];
251- if (is_array ($ events_value ) && $ backend_name !== null ) {
252- $ events_value = pt_resolve_backend_specific_value ($ events_value , $ backend_name );
250+ $ watchers_value = $ exp_event ['events ' ];
251+ if (is_array ($ watchers_value ) && $ backend_name !== null ) {
252+ $ watchers_value = pt_resolve_backend_specific_value ($ watchers_value , $ backend_name );
253253 }
254254
255- $ event_names = pt_event_flags_to_string ($ events_value );
256- echo " Event[ $ i]: $ event_names , user data: " . $ exp_event ['data ' ];
255+ $ watcher_names = pt_event_flags_to_string ($ watchers_value );
256+ echo " Event[ $ i]: $ watcher_names , user data: " . $ exp_event ['data ' ];
257257 if (isset ($ exp_event ['read ' ])) {
258258 echo ", read data: ' " . $ exp_event ['read ' ] . "' " ;
259259 }
0 commit comments