File tree Expand file tree Collapse file tree 4 files changed +8
-4
lines changed Expand file tree Collapse file tree 4 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ $watcher->watch(
3232 function (FsNotify\Event $event) {
3333 var_dump($event->getKind()); // kind of file/folder event
3434 var_dump($event->getPaths()); // paths
35+ return true; // return false if you do not want to continue
3536 }
3637);
3738```
@@ -50,7 +51,7 @@ class RecommendedWatcher
5051 public function remove(string $path): void;
5152
5253 /**
53- * @param callable(Event): void $handle
54+ * @param callable(Event): bool $handle
5455 * @throws WatchException
5556 */
5657 public function watch(callable $handle): void;
Original file line number Diff line number Diff line change @@ -190,7 +190,10 @@ pub fn get_module() -> Module {
190190 let kind = php_event. get_mut_property ( "kind" ) ;
191191 * kind = php_kind. into ( ) ;
192192
193- handler. call ( [ ZVal :: from ( php_event) ] ) ?;
193+ let call_result = handler. call ( [ ZVal :: from ( php_event) ] ) ?;
194+ if call_result. expect_bool ( ) ? == false {
195+ break ;
196+ }
194197 } ,
195198 Err ( error) => return Err ( NotifyError :: new ( error) . into ( ) ) ,
196199 }
Original file line number Diff line number Diff line change 1212$ watcher ->watch (function (FsNotify \Event $ event ) {
1313 var_dump ($ event ->getKind ());
1414 var_dump ($ event ->getPaths ());
15- exit ;
15+ return false ;
1616});
Original file line number Diff line number Diff line change 77try {
88 $ watcher = new FsNotify \RecommendedWatcher ();
99 $ watcher ->add (__DIR__ . '/unknown ' );
10- $ watcher ->watch (fn () => null );
10+ $ watcher ->watch (fn () => false );
1111} catch (FsNotify \WatchException ) {
1212 echo "caught exception " ;
1313}
You can’t perform that action at this time.
0 commit comments