-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfs_watcher.stub.php
More file actions
60 lines (53 loc) · 1.69 KB
/
fs_watcher.stub.php
File metadata and controls
60 lines (53 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/** @generate-class-entries */
namespace Async;
/**
* Represents a filesystem event detected by FileSystemWatcher.
*
* @strict-properties
* @not-serializable
*/
final readonly class FileSystemEvent
{
public string $path;
public ?string $filename;
public bool $renamed;
public bool $changed;
}
/**
* Persistent filesystem watcher that buffers events for async iteration.
*
* Monitors a file or directory for changes and delivers events via foreach or await().
* Two buffering modes: coalesce (merge events per file) or raw (every event separately).
*
* @strict-properties
* @not-serializable
*/
final class FileSystemWatcher implements Awaitable, \IteratorAggregate
{
/**
* Create a new filesystem watcher and start monitoring immediately.
*
* @param string $path Path to file or directory to watch.
* @param bool $recursive Watch subdirectories recursively.
* @param bool $coalesce Merge events per file (true) or deliver every event (false).
*/
public function __construct(string $path, bool $recursive = false, bool $coalesce = true) {}
/**
* Stop watching and terminate any active iteration.
* Idempotent — safe to call multiple times.
*/
public function close(): void {}
/**
* Check if the watcher has been closed.
*/
public function isClosed(): bool {}
/**
* Get async iterator for foreach support.
*
* Yields FileSystemEvent objects as filesystem changes are detected.
* Iteration suspends when no events are available and resumes on the next event.
* Iteration ends when close() is called or scope is cancelled.
*/
public function getIterator(): \Iterator {}
}