class InvokedProcess implements InvokedProcess

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable

Methods

Closure|null
guardProcessOutput(Process $process, callable|null $output)

Stop the process if its output callback fails.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

__construct(Process $process)

Create a new invoked process instance.

int|null
id()

Get the process ID if the process is still running.

string
command()

Get the command line for the process.

signal(int $signal)

Send a signal to the process.

int|null
stop(float $timeout = 10, int|null $signal = null)

Stop the process if it is still running.

bool
running()

Determine if the process is still running.

string
output()

Get the standard output for the process.

string
errorOutput()

Get the error output for the process.

string
latestOutput()

Get the latest standard output for the process.

string
latestErrorOutput()

Get the latest error output for the process.

void
ensureNotTimedOut()

Ensure that the process has not timed out.

wait(callable|null $output = null)

Wait for the process to finish.

waitUntil(callable|null $output = null)

Wait until the given callback returns true.

static void
flushState()

Flush all static state.

Details

protected Closure|null guardProcessOutput(Process $process, callable|null $output)

Stop the process if its output callback fails.

Parameters

Process $process
callable|null $output

Return Value

Closure|null

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 25
__construct(Process $process)

Create a new invoked process instance.

Parameters

Process $process

the underlying process instance

at line 32
int|null id()

Get the process ID if the process is still running.

Return Value

int|null

at line 40
string command()

Get the command line for the process.

Return Value

string

at line 48
InvokedProcess signal(int $signal)

Send a signal to the process.

Parameters

int $signal

Return Value

InvokedProcess

at line 58
int|null stop(float $timeout = 10, int|null $signal = null)

Stop the process if it is still running.

Parameters

float $timeout
int|null $signal

Return Value

int|null

at line 66
bool running()

Determine if the process is still running.

Return Value

bool

at line 74
string output()

Get the standard output for the process.

Return Value

string

at line 82
string errorOutput()

Get the error output for the process.

Return Value

string

at line 90
string latestOutput()

Get the latest standard output for the process.

Return Value

string

at line 98
string latestErrorOutput()

Get the latest error output for the process.

Return Value

string

at line 108
void ensureNotTimedOut()

Ensure that the process has not timed out.

Return Value

void

Exceptions

ProcessTimedOutException

at line 122
ProcessResult wait(callable|null $output = null)

Wait for the process to finish.

Parameters

callable|null $output

Return Value

ProcessResult

Exceptions

ProcessTimedOutException

at line 138
ProcessResult waitUntil(callable|null $output = null)

Wait until the given callback returns true.

Parameters

callable|null $output

Return Value

ProcessResult

Exceptions

ProcessTimedOutException

at line 156
static void flushState()

Flush all static state.

Return Value

void