Result
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
No description
Merge another result into this result. Data already existing in this result takes precedence over the data in the Result being merged.
Merge another result into this result. Data already existing in this result takes precedence over the data in the Result being merged.
Ask the provided parent class to inject all of the dependencies that it has and we need.
Tasks should always return a Result. However, they are also allowed to return NULL or an array to indicate success.
No description
Return a context useful for logging messages.
Add the results from the most recent task to the accumulated results from all tasks that have run so far, merging data as necessary.
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.
No description
No description
No description
No description
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
in
Data at line 30
array
getData()
No description
in
Data at line 38
string
getMessage()
No description
in
Data at line 46
setMessage(string $message)
No description
in
Data at line 60
$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.
in
Data at line 75
$this
update(ArrayObject $update)
Update the current data with the data provided in the parameter.
Provided data takes precedence.
in
Data at line 99
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.
in
Data at line 109
bool
hasExecutionTime()
No description
in
Data at line 117
null|float
getExecutionTime()
No description
in
Data at line 132
null|float
accumulateExecutionTime(array|float $duration)
Accumulate execution time
in
Data at line 149
string
accumulateMessage(string $message)
Accumulate the message.
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
protected OutputInterface
output()
No description
protected OutputInterface
stderr()
No description
protected OutputInterface
getOutput()
deprecated
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.
protected
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.
TaskInterface
getTask()
No description
TaskInterface
cloneTask()
No description
bool
__invoke()
deprecated
deprecated
No description
$this
stopOnFail()
No description
protected ResultPrinter
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).
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.