Documentation

Lint extends Process
in package

Class Lint.

Table of Contents

Constants

ERR  = 'err'
ITER_KEEP_OUTPUT  = 2
ITER_NON_BLOCKING  = 1
ITER_SKIP_ERR  = 8
ITER_SKIP_OUT  = 4
OUT  = 'out'
STATUS_READY  = 'ready'
STATUS_STARTED  = 'started'
STATUS_TERMINATED  = 'terminated'
STDERR  = 2
STDIN  = 0
STDOUT  = 1
TIMEOUT_PRECISION  = 0.2

Properties

$exitCodes  : array<string|int, mixed>
Exit codes translation table.
$callback  : mixed
$commandline  : mixed
$cwd  : mixed
$enhanceSigchildCompatibility  : mixed
$enhanceWindowsCompatibility  : mixed
$env  : mixed
$exitcode  : mixed
$fallbackStatus  : mixed
$hasCallback  : mixed
$idleTimeout  : mixed
$incrementalErrorOutputOffset  : mixed
$incrementalOutputOffset  : mixed
$inheritEnv  : mixed
$input  : mixed
$lastOutputTime  : mixed
$latestSignal  : mixed
$options  : mixed
$outputDisabled  : mixed
$process  : mixed
$processInformation  : mixed
$processPipes  : PipesInterface
$pty  : mixed
$sigchild  : mixed
$starttime  : mixed
$status  : mixed
$stderr  : mixed
$stdout  : mixed
$timeout  : mixed
$tty  : mixed
$useFileHandles  : mixed

Methods

__clone()  : mixed
__construct()  : mixed
Constructor.
__destruct()  : mixed
areEnvironmentVariablesInherited()  : bool
Returns whether environment variables will be inherited or not.
checkTimeout()  : mixed
Performs a check between the timeout definition and the time the process started.
clearErrorOutput()  : $this
Clears the process output.
clearOutput()  : $this
Clears the process output.
disableOutput()  : $this
Disables fetching output and error output from the underlying process.
enableOutput()  : $this
Enables fetching output and error output from the underlying process.
getCommandLine()  : string
Gets the command line to be executed.
getEnhanceSigchildCompatibility()  : bool
Returns whether sigchild compatibility mode is activated or not.
getEnhanceWindowsCompatibility()  : bool
Gets whether or not Windows compatibility is enabled.
getEnv()  : array<string|int, mixed>
Gets the environment variables.
getErrorOutput()  : string
Returns the current error output of the process (STDERR).
getExitCode()  : null|int
Returns the exit code returned by the process.
getExitCodeText()  : null|string
Returns a string representation for the exit code returned by the process.
getIdleTimeout()  : float|null
Gets the process idle timeout (max. time since last output).
getIncrementalErrorOutput()  : string
Returns the errorOutput incrementally.
getIncrementalOutput()  : string
Returns the output incrementally.
getInput()  : resource|string|Iterator|null
Gets the Process input.
getIterator()  : Generator
Returns an iterator to the output of the process, with the output type as keys (Process::OUT/ERR).
getOptions()  : array<string|int, mixed>
Gets the options for proc_open.
getOutput()  : string
Returns the current output of the process (STDOUT).
getPid()  : int|null
Returns the Pid (process identifier), if applicable.
getStatus()  : string
Gets the process status.
getStopSignal()  : int
Returns the number of the signal that caused the child process to stop its execution.
getSyntaxError()  : bool|array<string|int, mixed>
getSyntaxIssue()  : bool|array<string|int, mixed>
getTermSignal()  : int
Returns the number of the signal that caused the child process to terminate its execution.
getTimeout()  : float|null
Gets the process timeout (max. runtime).
getWorkingDirectory()  : string|null
Gets the working directory.
hasBeenSignaled()  : bool
Returns true if the child process has been terminated by an uncaught signal.
hasBeenStopped()  : bool
Returns true if the child process has been stopped by a signal.
hasSyntaxError()  : bool
hasSyntaxIssue()  : bool
inheritEnvironmentVariables()  : self
Sets whether environment variables will be inherited or not.
isOutputDisabled()  : bool
Returns true in case the output is disabled, false otherwise.
isPty()  : bool
Returns PTY state.
isPtySupported()  : bool
Returns whether PTY is supported on the current operating system.
isRunning()  : bool
Checks if the process is currently running.
isStarted()  : bool
Checks if the process has been started with no regard to the current state.
isSuccessful()  : bool
Checks if the process ended successfully.
isTerminated()  : bool
Checks if the process is terminated.
isTty()  : bool
Checks if the TTY mode is enabled.
mustRun()  : self
Runs the process.
parseError()  : array<string|int, mixed>
Parse error message.
restart()  : $this
Restarts the process.
run()  : int
Runs the process.
setCommandLine()  : self
Sets the command line to be executed.
setEnhanceSigchildCompatibility()  : self
Activates sigchild compatibility mode.
setEnhanceWindowsCompatibility()  : self
Sets whether or not Windows compatibility is enabled.
setEnv()  : self
Sets the environment variables.
setIdleTimeout()  : self
Sets the process idle timeout (max. time since last output).
setInput()  : self
Sets the input.
setOptions()  : self
Sets the options for proc_open.
setPty()  : self
Sets PTY mode.
setTimeout()  : self
Sets the process timeout (max. runtime).
setTty()  : self
Enables or disables the TTY mode.
setWorkingDirectory()  : self
Sets the current working directory.
signal()  : $this
Sends a POSIX signal to the process.
start()  : mixed
Starts the process and returns after writing the input to STDIN.
stop()  : int
Stops the process.
wait()  : int
Waits for the process to terminate.
buildCallback()  : Closure
Builds up the callback used by wait().
isSigchildEnabled()  : bool
Returns whether PHP has been compiled with the '--enable-sigchild' option or not.
updateStatus()  : mixed
Updates the status of the process, reads pipes.
close()  : int
Closes process resource, closes file handles, sets the exitcode.
doSignal()  : bool
Sends a POSIX signal to the process.
escapeArgument()  : string
Escapes a string to be used as a shell argument.
getDescriptors()  : array<string|int, mixed>
Creates the descriptors needed by the proc_open.
parseIssue()  : array<string|int, mixed>
Parse error message.
prepareWindowsCommandLine()  : mixed
readPipes()  : mixed
Reads pipes, executes callback.
readPipesForOutput()  : mixed
Reads pipes for the freshest output.
requireProcessIsStarted()  : mixed
Ensures the process is running or terminated, throws a LogicException if the process has a not started.
requireProcessIsTerminated()  : mixed
Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`.
resetProcessData()  : mixed
Resets data related to the latest run of the process.
validateTimeout()  : float|null
Validates and returns the filtered timeout.

Constants

ITER_KEEP_OUTPUT

public mixed ITER_KEEP_OUTPUT = 2

ITER_NON_BLOCKING

public mixed ITER_NON_BLOCKING = 1

ITER_SKIP_ERR

public mixed ITER_SKIP_ERR = 8

ITER_SKIP_OUT

public mixed ITER_SKIP_OUT = 4

STATUS_READY

public mixed STATUS_READY = 'ready'

STATUS_STARTED

public mixed STATUS_STARTED = 'started'

STATUS_TERMINATED

public mixed STATUS_TERMINATED = 'terminated'

TIMEOUT_PRECISION

public mixed TIMEOUT_PRECISION = 0.2

Properties

$exitCodes

Exit codes translation table.

public static array<string|int, mixed> $exitCodes = array( 0 => 'OK', 1 => 'General error', 2 => 'Misuse of shell builtins', 126 => 'Invoked command cannot execute', 127 => 'Command not found', 128 => 'Invalid exit argument', // signals 129 => 'Hangup', 130 => 'Interrupt', 131 => 'Quit and dump core', 132 => 'Illegal instruction', 133 => 'Trace/breakpoint trap', 134 => 'Process aborted', 135 => 'Bus error: "access to undefined portion of memory object"', 136 => 'Floating point exception: "erroneous arithmetic operation"', 137 => 'Kill (terminate immediately)', 138 => 'User-defined 1', 139 => 'Segmentation violation', 140 => 'User-defined 2', 141 => 'Write to pipe with no one reading', 142 => 'Signal raised by alarm', 143 => 'Termination (request to terminate)', // 144 - not defined 145 => 'Child process terminated, stopped (or continued*)', 146 => 'Continue if stopped', 147 => 'Stop executing temporarily', 148 => 'Terminal stop signal', 149 => 'Background process attempting to read from tty ("in")', 150 => 'Background process attempting to write to tty ("out")', 151 => 'Urgent data available on socket', 152 => 'CPU time limit exceeded', 153 => 'File size limit exceeded', 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"', 155 => 'Profiling timer expired', // 156 - not defined 157 => 'Pollable event', // 158 - not defined 159 => 'Bad syscall', )

User-defined errors must use exit codes in the 64-113 range.

$commandline

private mixed $commandline

$enhanceSigchildCompatibility

private mixed $enhanceSigchildCompatibility

$enhanceWindowsCompatibility

private mixed $enhanceWindowsCompatibility = true

$fallbackStatus

private mixed $fallbackStatus = array()

$hasCallback

private mixed $hasCallback = false

$idleTimeout

private mixed $idleTimeout

$incrementalErrorOutputOffset

private mixed $incrementalErrorOutputOffset = 0

$incrementalOutputOffset

private mixed $incrementalOutputOffset = 0

$inheritEnv

private mixed $inheritEnv = false

$lastOutputTime

private mixed $lastOutputTime

$latestSignal

private mixed $latestSignal

$options

private mixed $options = array('suppress_errors' => true)

$outputDisabled

private mixed $outputDisabled = false

$processInformation

private mixed $processInformation

$processPipes

private PipesInterface $processPipes

$sigchild

private static mixed $sigchild

$status

private mixed $status = self::STATUS_READY

$useFileHandles

private mixed $useFileHandles = false

Methods

__construct()

Constructor.

public __construct(string|array<string|int, mixed> $commandline[, string|null $cwd = null ][, array<string|int, mixed>|null $env = null ][, mixed|null $input = null ][, int|float|null $timeout = 60 ][, array<string|int, mixed> $options = null ]) : mixed
Parameters
$commandline : string|array<string|int, mixed>

The command line to run

$cwd : string|null = null

The working directory or null to use the working dir of the current PHP process

$env : array<string|int, mixed>|null = null

The environment variables or null to use the same environment as the current PHP process

$input : mixed|null = null

The input as stream resource, scalar or \Traversable, or null for no input

$timeout : int|float|null = 60

The timeout in seconds or null to disable

$options : array<string|int, mixed> = null

An array of options for proc_open

Tags
throws
RuntimeException

When proc_open is not installed

__destruct()

public __destruct() : mixed

areEnvironmentVariablesInherited()

Returns whether environment variables will be inherited or not.

public areEnvironmentVariablesInherited() : bool

since version 3.3, to be removed in 4.0. Environment variables will always be inherited.

Return values
bool

checkTimeout()

Performs a check between the timeout definition and the time the process started.

public checkTimeout() : mixed

In case you run a background process (with the start method), you should trigger this method regularly to ensure the process timeout

Tags
throws
ProcessTimedOutException

In case the timeout was reached

clearErrorOutput()

Clears the process output.

public clearErrorOutput() : $this
Return values
$this

clearOutput()

Clears the process output.

public clearOutput() : $this
Return values
$this

disableOutput()

Disables fetching output and error output from the underlying process.

public disableOutput() : $this
Tags
throws
RuntimeException

In case the process is already running

throws
LogicException

if an idle timeout is set

Return values
$this

enableOutput()

Enables fetching output and error output from the underlying process.

public enableOutput() : $this
Tags
throws
RuntimeException

In case the process is already running

Return values
$this

getCommandLine()

Gets the command line to be executed.

public getCommandLine() : string
Return values
string

The command to execute

getEnhanceSigchildCompatibility()

Returns whether sigchild compatibility mode is activated or not.

public getEnhanceSigchildCompatibility() : bool

since version 3.3, to be removed in 4.0. Sigchild compatibility will always be enabled.

Return values
bool

getEnhanceWindowsCompatibility()

Gets whether or not Windows compatibility is enabled.

public getEnhanceWindowsCompatibility() : bool

since version 3.3, to be removed in 4.0. Enhanced Windows compatibility will always be enabled.

This is true by default.

Return values
bool

getEnv()

Gets the environment variables.

public getEnv() : array<string|int, mixed>
Return values
array<string|int, mixed>

The current environment variables

getErrorOutput()

Returns the current error output of the process (STDERR).

public getErrorOutput() : string
Tags
throws
LogicException

in case the output has been disabled

throws
LogicException

In case the process is not started

Return values
string

The process error output

getExitCode()

Returns the exit code returned by the process.

public getExitCode() : null|int
Tags
throws
RuntimeException

In case --enable-sigchild is activated and the sigchild compatibility mode is disabled

Return values
null|int

The exit status code, null if the Process is not terminated

getExitCodeText()

Returns a string representation for the exit code returned by the process.

public getExitCodeText() : null|string

This method relies on the Unix exit code status standardization and might not be relevant for other operating systems.

Tags
see
http://tldp.org/LDP/abs/html/exitcodes.html
see
http://en.wikipedia.org/wiki/Unix_signal
Return values
null|string

A string representation for the exit status code, null if the Process is not terminated

getIdleTimeout()

Gets the process idle timeout (max. time since last output).

public getIdleTimeout() : float|null
Return values
float|null

The timeout in seconds or null if it's disabled

getIncrementalErrorOutput()

Returns the errorOutput incrementally.

public getIncrementalErrorOutput() : string

In comparison with the getErrorOutput method which always return the whole error output, this one returns the new error output since the last call.

Tags
throws
LogicException

in case the output has been disabled

throws
LogicException

In case the process is not started

Return values
string

The process error output since the last call

getIncrementalOutput()

Returns the output incrementally.

public getIncrementalOutput() : string

In comparison with the getOutput method which always return the whole output, this one returns the new output since the last call.

Tags
throws
LogicException

in case the output has been disabled

throws
LogicException

In case the process is not started

Return values
string

The process output since the last call

getInput()

Gets the Process input.

public getInput() : resource|string|Iterator|null
Return values
resource|string|Iterator|null

The Process input

getIterator()

Returns an iterator to the output of the process, with the output type as keys (Process::OUT/ERR).

public getIterator([int $flags = 0 ]) : Generator
Parameters
$flags : int = 0

A bit field of Process::ITER_* flags

Tags
throws
LogicException

in case the output has been disabled

throws
LogicException

In case the process is not started

Return values
Generator

getOptions()

Gets the options for proc_open.

public getOptions() : array<string|int, mixed>

since version 3.3, to be removed in 4.0.

Return values
array<string|int, mixed>

The current options

getOutput()

Returns the current output of the process (STDOUT).

public getOutput() : string
Tags
throws
LogicException

in case the output has been disabled

throws
LogicException

In case the process is not started

Return values
string

The process output

getPid()

Returns the Pid (process identifier), if applicable.

public getPid() : int|null
Return values
int|null

The process id if running, null otherwise

getStatus()

Gets the process status.

public getStatus() : string

The status is one of: ready, started, terminated.

Return values
string

The current process status

getStopSignal()

Returns the number of the signal that caused the child process to stop its execution.

public getStopSignal() : int

It is only meaningful if hasBeenStopped() returns true.

Tags
throws
LogicException

In case the process is not terminated

Return values
int

getSyntaxError()

public getSyntaxError() : bool|array<string|int, mixed>
Return values
bool|array<string|int, mixed>

getSyntaxIssue()

public getSyntaxIssue() : bool|array<string|int, mixed>
Return values
bool|array<string|int, mixed>

getTermSignal()

Returns the number of the signal that caused the child process to terminate its execution.

public getTermSignal() : int

It is only meaningful if hasBeenSignaled() returns true.

Tags
throws
RuntimeException

In case --enable-sigchild is activated

throws
LogicException

In case the process is not terminated

Return values
int

getTimeout()

Gets the process timeout (max. runtime).

public getTimeout() : float|null
Return values
float|null

The timeout in seconds or null if it's disabled

getWorkingDirectory()

Gets the working directory.

public getWorkingDirectory() : string|null
Return values
string|null

The current working directory or null on failure

hasBeenSignaled()

Returns true if the child process has been terminated by an uncaught signal.

public hasBeenSignaled() : bool

It always returns false on Windows.

Tags
throws
RuntimeException

In case --enable-sigchild is activated

throws
LogicException

In case the process is not terminated

Return values
bool

hasBeenStopped()

Returns true if the child process has been stopped by a signal.

public hasBeenStopped() : bool

It always returns false on Windows.

Tags
throws
LogicException

In case the process is not terminated

Return values
bool

hasSyntaxError()

public hasSyntaxError() : bool
Return values
bool

hasSyntaxIssue()

public hasSyntaxIssue() : bool
Return values
bool

inheritEnvironmentVariables()

Sets whether environment variables will be inherited or not.

public inheritEnvironmentVariables([bool $inheritEnv = true ]) : self
Parameters
$inheritEnv : bool = true
Return values
self

The current Process instance

isOutputDisabled()

Returns true in case the output is disabled, false otherwise.

public isOutputDisabled() : bool
Return values
bool

isPty()

Returns PTY state.

public isPty() : bool
Return values
bool

isPtySupported()

Returns whether PTY is supported on the current operating system.

public static isPtySupported() : bool
Return values
bool

isRunning()

Checks if the process is currently running.

public isRunning() : bool
Return values
bool

true if the process is currently running, false otherwise

isStarted()

Checks if the process has been started with no regard to the current state.

public isStarted() : bool
Return values
bool

true if status is ready, false otherwise

isSuccessful()

Checks if the process ended successfully.

public isSuccessful() : bool
Return values
bool

true if the process ended successfully, false otherwise

isTerminated()

Checks if the process is terminated.

public isTerminated() : bool
Return values
bool

true if process is terminated, false otherwise

isTty()

Checks if the TTY mode is enabled.

public isTty() : bool
Return values
bool

true if the TTY mode is enabled, false otherwise

mustRun()

Runs the process.

public mustRun([callable|null $callback = null ]) : self

This is identical to run() except that an exception is thrown if the process exits with a non-zero exit code.

Parameters
$callback : callable|null = null
Tags
throws
RuntimeException

if PHP was compiled with --enable-sigchild and the enhanced sigchild compatibility mode is not enabled

throws
ProcessFailedException

if the process didn't terminate successfully

final

since version 3.3

Return values
self

parseError()

Parse error message.

public parseError(string $message) : array<string|int, mixed>
Parameters
$message : string
Return values
array<string|int, mixed>

restart()

Restarts the process.

public restart([callable|null $callback = null ]) : $this

Be warned that the process is cloned before being started.

Parameters
$callback : callable|null = null

A PHP callback to run whenever there is some output available on STDOUT or STDERR

Tags
throws
RuntimeException

When process can't be launched

throws
RuntimeException

When process is already running

see
start()
final

since version 3.3

Return values
$this

run()

Runs the process.

public run([callable|null $callback = null ]) : int

The callback receives the type of output (out or err) and some bytes from the output in real-time. It allows to have feedback from the independent process during execution.

The STDOUT and STDERR are also available after the process is finished via the getOutput() and getErrorOutput() methods.

Parameters
$callback : callable|null = null

A PHP callback to run whenever there is some output available on STDOUT or STDERR

Tags
throws
RuntimeException

When process can't be launched

throws
RuntimeException

When process stopped after receiving signal

throws
LogicException

In case a callback is provided and output has been disabled

final

since version 3.3

Return values
int

The exit status code

setCommandLine()

Sets the command line to be executed.

public setCommandLine(string|array<string|int, mixed> $commandline) : self
Parameters
$commandline : string|array<string|int, mixed>

The command to execute

Return values
self

The current Process instance

setEnhanceSigchildCompatibility()

Activates sigchild compatibility mode.

public setEnhanceSigchildCompatibility(bool $enhance) : self

since version 3.3, to be removed in 4.0.

Sigchild compatibility mode is required to get the exit code and determine the success of a process when PHP has been compiled with the --enable-sigchild option

Parameters
$enhance : bool
Return values
self

The current Process instance

setEnhanceWindowsCompatibility()

Sets whether or not Windows compatibility is enabled.

public setEnhanceWindowsCompatibility(bool $enhance) : self

since version 3.3, to be removed in 4.0. Enhanced Windows compatibility will always be enabled.

Parameters
$enhance : bool
Return values
self

The current Process instance

setEnv()

Sets the environment variables.

public setEnv(array<string|int, mixed> $env) : self

An environment variable value should be a string. If it is an array, the variable is ignored. If it is false or null, it will be removed when env vars are otherwise inherited.

That happens in PHP when 'argv' is registered into the $_ENV array for instance.

Parameters
$env : array<string|int, mixed>

The new environment variables

Return values
self

The current Process instance

setIdleTimeout()

Sets the process idle timeout (max. time since last output).

public setIdleTimeout(int|float|null $timeout) : self

To disable the timeout, set this value to null.

Parameters
$timeout : int|float|null

The timeout in seconds

Tags
throws
LogicException

if the output is disabled

throws
InvalidArgumentException

if the timeout is negative

Return values
self

The current Process instance

setInput()

Sets the input.

public setInput(resource|scalar|Traversable|null $input) : self

This content will be passed to the underlying process standard input.

Parameters
$input : resource|scalar|Traversable|null

The content

Tags
throws
LogicException

In case the process is running

Return values
self

The current Process instance

setOptions()

Sets the options for proc_open.

public setOptions(array<string|int, mixed> $options) : self

since version 3.3, to be removed in 4.0.

Parameters
$options : array<string|int, mixed>

The new options

Return values
self

The current Process instance

setPty()

Sets PTY mode.

public setPty(bool $bool) : self
Parameters
$bool : bool
Return values
self

setTimeout()

Sets the process timeout (max. runtime).

public setTimeout(int|float|null $timeout) : self

To disable the timeout, set this value to null.

Parameters
$timeout : int|float|null

The timeout in seconds

Tags
throws
InvalidArgumentException

if the timeout is negative

Return values
self

The current Process instance

setTty()

Enables or disables the TTY mode.

public setTty(bool $tty) : self
Parameters
$tty : bool

True to enabled and false to disable

Tags
throws
RuntimeException

In case the TTY mode is not supported

Return values
self

The current Process instance

setWorkingDirectory()

Sets the current working directory.

public setWorkingDirectory(string $cwd) : self
Parameters
$cwd : string

The new working directory

Return values
self

The current Process instance

signal()

Sends a POSIX signal to the process.

public signal(int $signal) : $this
Parameters
$signal : int

A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)

Tags
throws
LogicException

In case the process is not running

throws
RuntimeException

In case --enable-sigchild is activated and the process can't be killed

throws
RuntimeException

In case of failure

Return values
$this

start()

Starts the process and returns after writing the input to STDIN.

public start([callable|null $callback = null ]) : mixed

This method blocks until all STDIN data is sent to the process then it returns while the process runs in the background.

The termination of the process can be awaited with wait().

The callback receives the type of output (out or err) and some bytes from the output in real-time while writing the standard input to the process. It allows to have feedback from the independent process during execution.

Parameters
$callback : callable|null = null

A PHP callback to run whenever there is some output available on STDOUT or STDERR

Tags
throws
RuntimeException

When process can't be launched

throws
RuntimeException

When process is already running

throws
LogicException

In case a callback is provided and output has been disabled

stop()

Stops the process.

public stop([int|float $timeout = 10 ][, int $signal = null ]) : int
Parameters
$timeout : int|float = 10

The timeout in seconds

$signal : int = null

A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)

Return values
int

The exit-code of the process

wait()

Waits for the process to terminate.

public wait([callable|null $callback = null ]) : int

The callback receives the type of output (out or err) and some bytes from the output in real-time while writing the standard input to the process. It allows to have feedback from the independent process during execution.

Parameters
$callback : callable|null = null

A valid PHP callback

Tags
throws
RuntimeException

When process timed out

throws
RuntimeException

When process stopped after receiving signal

throws
LogicException

When process is not yet started

Return values
int

The exitcode of the process

buildCallback()

Builds up the callback used by wait().

protected buildCallback([callable|null $callback = null ]) : Closure

The callbacks adds all occurred output to the specific buffer and calls the user callback (if present) with the received output.

Parameters
$callback : callable|null = null

The user defined PHP callback

Return values
Closure

A PHP closure

isSigchildEnabled()

Returns whether PHP has been compiled with the '--enable-sigchild' option or not.

protected isSigchildEnabled() : bool
Return values
bool

updateStatus()

Updates the status of the process, reads pipes.

protected updateStatus(bool $blocking) : mixed
Parameters
$blocking : bool

Whether to use a blocking read call

close()

Closes process resource, closes file handles, sets the exitcode.

private close() : int
Return values
int

The exitcode

doSignal()

Sends a POSIX signal to the process.

private doSignal(int $signal, bool $throwException) : bool
Parameters
$signal : int

A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)

$throwException : bool

Whether to throw exception in case signal failed

Tags
throws
LogicException

In case the process is not running

throws
RuntimeException

In case --enable-sigchild is activated and the process can't be killed

throws
RuntimeException

In case of failure

Return values
bool

True if the signal was sent successfully, false otherwise

escapeArgument()

Escapes a string to be used as a shell argument.

private escapeArgument(string $argument) : string
Parameters
$argument : string

The argument that will be escaped

Return values
string

The escaped argument

getDescriptors()

Creates the descriptors needed by the proc_open.

private getDescriptors() : array<string|int, mixed>
Return values
array<string|int, mixed>

parseIssue()

Parse error message.

private parseIssue(string $message) : array<string|int, mixed>
Parameters
$message : string
Return values
array<string|int, mixed>

prepareWindowsCommandLine()

private prepareWindowsCommandLine(mixed $cmd, array<string|int, mixed> &$envBackup[, array<string|int, mixed> &$env = null ]) : mixed
Parameters
$cmd : mixed
$envBackup : array<string|int, mixed>
$env : array<string|int, mixed> = null

readPipes()

Reads pipes, executes callback.

private readPipes(bool $blocking, bool $close) : mixed
Parameters
$blocking : bool

Whether to use blocking calls or not

$close : bool

Whether to close file handles or not

readPipesForOutput()

Reads pipes for the freshest output.

private readPipesForOutput(string $caller[, bool $blocking = false ]) : mixed
Parameters
$caller : string

The name of the method that needs fresh outputs

$blocking : bool = false

Whether to use blocking calls or not

Tags
throws
LogicException

in case output has been disabled or process is not started

requireProcessIsStarted()

Ensures the process is running or terminated, throws a LogicException if the process has a not started.

private requireProcessIsStarted(string $functionName) : mixed
Parameters
$functionName : string

The function name that was called

Tags
throws
LogicException

If the process has not run.

requireProcessIsTerminated()

Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`.

private requireProcessIsTerminated(string $functionName) : mixed
Parameters
$functionName : string

The function name that was called

Tags
throws
LogicException

If the process is not yet terminated.

resetProcessData()

Resets data related to the latest run of the process.

private resetProcessData() : mixed

validateTimeout()

Validates and returns the filtered timeout.

private validateTimeout(int|float|null $timeout) : float|null
Parameters
$timeout : int|float|null
Tags
throws
InvalidArgumentException

if the given timeout is a negative number

Return values
float|null

        
On this page

Search results