Skip to content

Invocation

Rasuvaeff\Understudy\Invocation

ClassPackage: rasuvaeff/understudySourceVersion: 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

php
__construct(
    non-empty-string $method,
    list $args,
    positive-int $sequence,
    ?string $file = NULL,
    ?int $line = NULL,
    ?object $double = NULL,
    list $liveArgs = [],
)
ParameterTypeDefaultDescription
$methodnon-empty-stringrequired
$argslistrequired
$sequencepositive-intrequiredposition in this context's global call order
$file?stringNULL
$line?intNULL
$double?objectNULL
$liveArgslist[]the arguments as the caller still holds them, references included — what delegation needs, where $args is a reading of them

Methods

argsAfter()

php
argsAfter(): ?array

What 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()

php
recordFinalArguments(list $args): void

belongsTo()

php
belongsTo(object $double): bool

callOriginal()

php
callOriginal(): mixed

Delegates 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()

php
recordOutcome(Outcome $outcome): void

recordReturned()

php
recordReturned(mixed $value): void

Records 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()

php
recordDiscardedReturn(): void

Records 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()

php
isReturnDiscarded(): bool

recordThrown()

php
recordThrown(Throwable $thrown): void

markAccounted()

php
markAccounted(): void

Marks this call as accounted for: an expectation matched it, or a verification claimed it. nothingElse() is the question this answers.

isAccounted()

php
isAccounted(): bool

didReturn()

php
didReturn(): bool

didThrow()

php
didThrow(): bool

returned()

php
returned(): mixed

thrown()

php
thrown(): ?Throwable