Invocation
Rasuvaeff\Understudy\Invocation
Class — Package: rasuvaeff/understudy — Source — Version: v0.4.1
One recorded call on an understudy.
Instances are handed to answers() callbacks while the call is still in flight, and read back afterwards through Understudy::calls(). The outcome is therefore filled in once, by the dispatcher, after the answer is known.
Constructor
__construct(
non-empty-string $method,
list $args,
positive-int $sequence,
?string $file = NULL,
?int $line = NULL,
?object $double = NULL,
list $liveArgs = [],
)| Parameter | Type | Default | Description |
|---|---|---|---|
$method | non-empty-string | required | |
$args | list | required | |
$sequence | positive-int | required | position in this context's global call order |
$file | ?string | NULL | |
$line | ?int | NULL | |
$double | ?object | NULL | |
$liveArgs | list | [] | the arguments as the caller still holds them, references included — what delegation needs, where $args is a reading of them |
Methods
argsAfter()
argsAfter(): ?arrayWhat the arguments were once the call had been answered.
Only a method with a by-reference parameter has one: for every other method the answer cannot change what was passed, and taking the snapshot anyway would cost every call in the suite. Null means "same as $args".
recordFinalArguments()
recordFinalArguments(list $args): voidbelongsTo()
belongsTo(object $double): boolcallOriginal()
callOriginal(): mixedDelegates this call to the double's real instance and returns what it answered — the answers() escape hatch for "behave normally, except here".
Throws:
Without a forwarding target it raises OriginalCallUnavailable rather than reaching for the parent implementation: the double's constructor never ran, so the parent body would work over state that does not exist.
recordOutcome()
recordOutcome(Outcome $outcome): voidrecordReturned()
recordReturned(mixed $value): voidRecords a returned value without allocating an Outcome wrapper. The wrapper remains supported by recordOutcome() for internal compatibility; dispatch uses this scalar path because every call reaches it.
recordDiscardedReturn()
recordDiscardedReturn(): voidRecords that the call returned without keeping what it returned — the lean double's reading of an outcome. The distinction from "threw" and from "returned null" is kept: didReturn() stays true, and returned() refuses by name instead of inventing a value.
isReturnDiscarded()
isReturnDiscarded(): boolrecordThrown()
recordThrown(Throwable $thrown): voidmarkAccounted()
markAccounted(): voidMarks this call as accounted for: an expectation matched it, or a verification claimed it. nothingElse() is the question this answers.
isAccounted()
isAccounted(): booldidReturn()
didReturn(): booldidThrow()
didThrow(): boolreturned()
returned(): mixedthrown()
thrown(): ?Throwable