class Result extends ResultData implements OutputAwareInterface, InflectionInterface (View source)

Traits

Constants

EXITCODE_OK

EXITCODE_ERROR

EXITCODE_MISSING_OPTIONS

Symfony Console handles these conditions; Robo returns the status code selected by Symfony. These are here for documentation purposes.

EXITCODE_COMMAND_NOT_FOUND

EXITCODE_USER_CANCEL

The command was aborted because the user chose to cancel it at some prompt.

This exit code is arbitrarily the same as EX_TEMPFAIL in sysexits.h, although note that shell error codes are distinct from C exit codes, so this alignment not particularly meaningful.

Properties

protected string $message from  Data
protected int $exitCode from  ResultData
protected OutputInterface $output from  OutputAwareTrait
static bool $stopOnFail
protected TaskInterface $task

Methods

__construct(TaskInterface $task, int $exitCode, string $message = '', array $data = [])

No description

array
getData()

No description

from  Data
string
getMessage()

No description

from  Data
setMessage(string $message)

No description

from  Data
$this
merge(Data $result)

Merge another result into this result. Data already existing in this result takes precedence over the data in the Result being merged.

from  Data
$this
update(ArrayObject $update)

Update the current data with the data provided in the parameter.

from  Data
array
mergeData(array $data)

Merge another result into this result. Data already existing in this result takes precedence over the data in the Result being merged.

from  Data
bool
hasExecutionTime()

No description

from  Data
null|float
getExecutionTime()

No description

from  Data
null|float
accumulateExecutionTime(array|float $duration)

Accumulate execution time

from  Data
string
accumulateMessage(string $message)

Accumulate the message.

from  Data
static ResultData
message(string $message, array $data = [])

No description

static ResultData
cancelled(string $message = '', array $data = [])

No description

getExitCode()

No description

getOutputData()

No description

alreadyPrinted()

Indicate that the message in this data has already been displayed.

provideOutputdata()

Opt-in to providing the result message as the output data

bool
wasSuccessful()

No description

bool
wasCancelled()

No description

$this
inflect(InflectionInterface|mixed $parent)

Ask the provided parent class to inject all of the dependencies that it has and we need.

$this
setOutput(OutputInterface $output)

No description

OutputInterface
output()

No description

OutputInterface
stderr()

No description

OutputInterface
getOutput() deprecated

Backwards compatibility

static Result
ensureResult(TaskInterface $task, $result)

Tasks should always return a Result. However, they are also allowed to return NULL or an array to indicate success.

printResult()

No description

static Result
errorMissingExtension(TaskInterface $task, string $extension, string $service)

No description

static Result
errorMissingPackage(TaskInterface $task, string $class, string $package)

No description

static Result
error(TaskInterface $task, string $message, array $data = [])

No description

static Result
fromException(TaskInterface $task, Exception $e, array $data = [])

No description

static Result
success(TaskInterface $task, string $message = '', array $data = [])

No description

array
getContext()

Return a context useful for logging messages.

accumulate(int|string $key, Result $taskResult)

Add the results from the most recent task to the accumulated results from all tasks that have run so far, merging data as necessary.

static bool
isUnnamed(int|string $key)

We assume that named values (e.g. for associative array keys) are non-numeric; numeric keys are presumed to simply be the index of an array, and therefore insignificant.

getTask()

No description

cloneTask()

No description

bool
__invoke() deprecated

No description

$this
stopOnFail()

No description

resultPrinter()

No description

injectDependencies(mixed $child)

Take all dependencies availble to this task and inject any that are needed into the provided task. The general pattern is that, for every FooAwareInterface that this class implements, it should test to see if the child also implements the same interface, and if so, should call $child->setFoo($this->foo).

Details

__construct(TaskInterface $task, int $exitCode, string $message = '', array $data = [])

No description

Parameters

TaskInterface $task
int $exitCode
string $message
array $data

array getData()

No description

Return Value

array

string getMessage()

No description

Return Value

string

setMessage(string $message)

No description

Parameters

string $message

$this merge(Data $result)

Merge another result into this result. Data already existing in this result takes precedence over the data in the Result being merged.

Parameters

Data $result

Return Value

$this

$this update(ArrayObject $update)

Update the current data with the data provided in the parameter.

Provided data takes precedence.

Parameters

ArrayObject $update

Return Value

$this

array mergeData(array $data)

Merge another result into this result. Data already existing in this result takes precedence over the data in the Result being merged.

$data['message'] is handled specially, and is appended to $this->message if set.

Parameters

array $data

Return Value

array

bool hasExecutionTime()

No description

Return Value

bool

null|float getExecutionTime()

No description

Return Value

null|float

null|float accumulateExecutionTime(array|float $duration)

Accumulate execution time

Parameters

array|float $duration

Return Value

null|float

string accumulateMessage(string $message)

Accumulate the message.

Parameters

string $message

Return Value

string

static ResultData message(string $message, array $data = [])

No description

Parameters

string $message
array $data

Return Value

ResultData

static ResultData cancelled(string $message = '', array $data = [])

No description

Parameters

string $message
array $data

Return Value

ResultData

getExitCode()

No description

getOutputData()

No description

alreadyPrinted()

Indicate that the message in this data has already been displayed.

provideOutputdata()

Opt-in to providing the result message as the output data

bool wasSuccessful()

No description

Return Value

bool

bool wasCancelled()

No description

Return Value

bool

$this inflect(InflectionInterface|mixed $parent)

Ask the provided parent class to inject all of the dependencies that it has and we need.

Parameters

InflectionInterface|mixed $parent

Return Value

$this

$this setOutput(OutputInterface $output)

No description

Parameters

OutputInterface $output

Return Value

$this

See also

\Robo\Contract\OutputAwareInterface::setOutput()

protected OutputInterface output()

No description

Return Value

OutputInterface

protected OutputInterface stderr()

No description

Return Value

OutputInterface

protected OutputInterface getOutput() deprecated

deprecated

Backwards compatibility

Return Value

OutputInterface

static Result ensureResult(TaskInterface $task, $result)

Tasks should always return a Result. However, they are also allowed to return NULL or an array to indicate success.

Parameters

TaskInterface $task
$result

Return Value

Result

protected printResult()

No description

static Result errorMissingExtension(TaskInterface $task, string $extension, string $service)

No description

Parameters

TaskInterface $task
string $extension
string $service

Return Value

Result

static Result errorMissingPackage(TaskInterface $task, string $class, string $package)

No description

Parameters

TaskInterface $task
string $class
string $package

Return Value

Result

static Result error(TaskInterface $task, string $message, array $data = [])

No description

Parameters

TaskInterface $task
string $message
array $data

Return Value

Result

static Result fromException(TaskInterface $task, Exception $e, array $data = [])

No description

Parameters

TaskInterface $task
Exception $e
array $data

Return Value

Result

static Result success(TaskInterface $task, string $message = '', array $data = [])

No description

Parameters

TaskInterface $task
string $message
array $data

Return Value

Result

array getContext()

Return a context useful for logging messages.

Return Value

array

accumulate(int|string $key, Result $taskResult)

Add the results from the most recent task to the accumulated results from all tasks that have run so far, merging data as necessary.

Parameters

int|string $key
Result $taskResult

static bool isUnnamed(int|string $key)

We assume that named values (e.g. for associative array keys) are non-numeric; numeric keys are presumed to simply be the index of an array, and therefore insignificant.

Parameters

int|string $key

Return Value

bool

TaskInterface getTask()

No description

Return Value

TaskInterface

TaskInterface cloneTask()

No description

Return Value

TaskInterface

bool __invoke() deprecated

deprecated since 1.0.

No description

Return Value

bool

See also

wasSuccessful()

$this stopOnFail()

No description

Return Value

$this

protected ResultPrinter resultPrinter()

No description

Return Value

ResultPrinter

injectDependencies(mixed $child)

Take all dependencies availble to this task and inject any that are needed into the provided task. The general pattern is that, for every FooAwareInterface that this class implements, it should test to see if the child also implements the same interface, and if so, should call $child->setFoo($this->foo).

The benefits of this are pretty large. Any time an object that implements InflectionInterface is created, just call $child->inflect($this), and any available optional dependencies will be hooked up via setter injection.

The required dependencies of an object should be provided via constructor injection, not inflection.

Parameters

mixed $child

An object with one or more *AwareInterfaces implemented.