Skip to content

API reference

Generated by reflection (docs/scripts/reflect-api.php) over all five packages' src/, not written by hand — every signature, parameter and default value here is read straight from the code, not transcribed from it. Only @api-annotated types get a page; @internal classes are implementation detail and stay undocumented on purpose.

SectionWhat is in it
Functionsthe 4 free functions that are the primary surface
Exceptionsevery @api type that implements Throwable
Static analysis rulesthe 5 PHPStan identifiers and the Psalm issue type — the whole contract of two packages that have no @api class

Engine

TypeKindSummary
ArgclassArgument matchers, usable only inside a specification closure:
CaptorclassA typed argument captor, built by Arg::captor().
CardinalityclassHow many times a call is allowed to happen.
AmbiguousDefaultFactoryclassTwo registered default factories are equally close to the requested type.
BypassUnavailableclassbypassFinals() cannot do what was asked of it.
CannotWireclasswire() cannot build the subject, or cannot decide what to pass it.
ConflictingExpectationclassA when() or expect() names a call another registration already specifies, and the two would…
ContextOwnershipViolationclassConfiguration and verification belong to the context that created a double.
ForgottenDoubleclassA double outlived the context that created it — almost always a double kept in a static property…
ForwardingTargetMismatchclassThe instance offered as a forwarding target does not satisfy what the double stands in for.
InvalidCallSpecificationclassThe closure handed to when()/verify()/calls() did not describe one call the way a specification…
InvalidDefaultValueclassA registered default factory produced a value the contract cannot hold.
MatcherLeakedclassA matcher reached a real call instead of a specification closure.
NeverMethodCalledclassA method declared : never was called without an expectation that throws.
NoDefaultValueclassA loose understudy had to answer a call, but the declared return type has no safe default.
NothingCapturedclassCaptor::last() was read before any matched call carried a value through its capture() argument.
OriginalCallUnavailableclasscallOriginal() was asked to delegate, and there is nothing to delegate to.
OriginalReturnTypeViolationclassA forwarded call returned an object the double cannot stand in for.
OutcomeUnavailableclassAn invocation's outcome was read as the wrong kind: a returned value asked of a call that threw.
StrictModeViolationclassA strict understudy received a call no expectation matched.
UnderstudyErrorinterfaceImplemented by every exception this library throws, so a test can catch misuse of Understudy…
UnsupportedTargetclassThe requested target cannot be doubled, and no option would make it work without the user changing…
VerificationFailedclassA verification about what the code under test did (or did not) do failed.
ExpectBuilderclassConfigures a call the code under test is expected to make.
FailureKindenumWhat kind of verification claim a VerificationFailure reports.
InvocationclassOne recorded call on an understudy.
OutcomeclassHow one call ended: with a value or with a throwable.
ModeenumHow an understudy answers a call no expectation matched.
UnderstudyclassThe whole public surface, as static methods so that an understudy itself can stay free of service…
VerificationFailureclassThe structured half of one verification failure — the same facts the rendered message states,…
WhenBuilderclassConfigures what a stubbed call does.

Testo adapter

TypeKindSummary
UnderstudyInterceptorclassEnds every test with understudy's own bookkeeping done for it.
UnderstudyPluginclassRegisters UnderstudyInterceptor so every test of the suite ends with understudy's own bookkeeping…

PHPUnit adapter

TypeKindSummary
UnderstudyPHPUnitIntegrationtraitEnds every PHPUnit test with understudy's own bookkeeping done for it.

Psalm plugin

TypeKindSummary
UnderstudyMisuseclassA specification that cannot mean what it says.
PluginclassEntry point registered through extra.psalm.pluginClass, so `vendor/bin/psalm-plugin enable…