class FswatchDriver extends AbstractDriver

Properties

protected Channel|null $stopSignal from  AbstractDriver
protected bool $stopping from  AbstractDriver
protected array<string, resource> $processes
protected array<string, resource> $pipes

Methods

__construct(Option $option)

No description

bool
isDarwin()

Determine if the current OS is macOS.

void
stop()

Stop the active fswatch processes.

bool
isStopping()

Determine whether the driver has been stopped.

void
watchAtInterval(float $seconds, callable $scan)

Run a polling scan until the driver is stopped.

array
resolveTargets(array $watchPaths)

Resolve configured watch paths to absolute targets.

array
groupWatchPathsByTarget(array $watchPaths)

Group watch paths by their resolved target.

array
existingTargets(array $targets)

Filter targets that currently exist.

array
exec(string $command)

Execute a shell command using Swoole's coroutine-aware exec.

string
shellArguments(array $arguments)

Escape a list of arguments for interpolation into a shell command.

void
watch(Channel $channel)

Watch for file changes using fswatch.

void
processOutput(string $buffer, string $chunk, Channel $channel, array $watchPaths, array $watchTargets)

Process complete NUL-delimited paths while retaining a partial tail.

void
openProcesses(array $groups)

Open every configured fswatch process group.

void
openProcess(string $group, array $operands, bool $recursive)

Open one fswatch subprocess and retain its output pipe.

void
closeProcesses()

Close every process resource owned by the active watch lifecycle.

array
resolveWatchTargets(array $watchPaths)

Resolve command operands and canonical matcher mappings.

array
groupWatchTargets(array $targets)

Group watch targets by the recursion depth their process requires.

bool
isContainedBy(string $path, string $parent)

Determine whether a path is equal to or nested beneath another path.

bool
shouldStopWatching(Channel $channel)

Determine whether the active watch loop should stop.

array
getCommand(array $operands, bool $recursive)

Build the fswatch command arguments.

Details

at line 22
__construct(Option $option)

No description

Parameters

Option $option

in AbstractDriver at line 26
bool isDarwin()

Determine if the current OS is macOS.

Return Value

bool

at line 162
void stop()

Stop the active fswatch processes.

Return Value

void

in AbstractDriver at line 51
protected bool isStopping()

Determine whether the driver has been stopped.

The state may change while hooked I/O yields to another coroutine.

Return Value

bool

in AbstractDriver at line 59
protected void watchAtInterval(float $seconds, callable $scan)

Run a polling scan until the driver is stopped.

Parameters

float $seconds
callable $scan

Return Value

void

in AbstractDriver at line 96
protected array resolveTargets(array $watchPaths)

Resolve configured watch paths to absolute targets.

Parameters

array $watchPaths

Return Value

array

in AbstractDriver at line 116
protected array groupWatchPathsByTarget(array $watchPaths)

Group watch paths by their resolved target.

Parameters

array $watchPaths

Return Value

array

in AbstractDriver at line 137
protected array existingTargets(array $targets)

Filter targets that currently exist.

Parameters

array $targets

Return Value

array

in AbstractDriver at line 149
protected array exec(string $command)

Execute a shell command using Swoole's coroutine-aware exec.

Every interpolated argument must be escaped before it reaches this boundary.

Parameters

string $command

Return Value

array

in AbstractDriver at line 165
protected string shellArguments(array $arguments)

Escape a list of arguments for interpolation into a shell command.

Parameters

array $arguments

Return Value

string

at line 35
void watch(Channel $channel)

Watch for file changes using fswatch.

Parameters

Channel $channel

Return Value

void

at line 111
protected void processOutput(string $buffer, string $chunk, Channel $channel, array $watchPaths, array $watchTargets)

Process complete NUL-delimited paths while retaining a partial tail.

Parameters

string $buffer
string $chunk
Channel $channel
array $watchPaths
array $watchTargets

Return Value

void

at line 178
protected void openProcesses(array $groups)

Open every configured fswatch process group.

Parameters

array $groups

Return Value

void

at line 190
protected void openProcess(string $group, array $operands, bool $recursive)

Open one fswatch subprocess and retain its output pipe.

Parameters

string $group
array $operands
bool $recursive

Return Value

void

at line 218
protected void closeProcesses()

Close every process resource owned by the active watch lifecycle.

Return Value

void

at line 254
protected array resolveWatchTargets(array $watchPaths)

Resolve command operands and canonical matcher mappings.

Parameters

array $watchPaths

Return Value

array

at line 298
protected array groupWatchTargets(array $targets)

Group watch targets by the recursion depth their process requires.

Parameters

array $targets

Return Value

array

at line 362
protected bool isContainedBy(string $path, string $parent)

Determine whether a path is equal to or nested beneath another path.

Both paths must be canonical because a literal path can escape its lexical parent through a symlink.

Parameters

string $path
string $parent

Return Value

bool

at line 383
protected bool shouldStopWatching(Channel $channel)

Determine whether the active watch loop should stop.

The state may change while hooked I/O yields to another coroutine.

Parameters

Channel $channel

Return Value

bool

at line 394
protected array getCommand(array $operands, bool $recursive)

Build the fswatch command arguments.

Parameters

array $operands
bool $recursive

Return Value

array