function Matcher::invoked
Throws
MethodNameNotConfiguredException
File
-
vendor/
phpunit/ phpunit/ src/ Framework/ MockObject/ Runtime/ Matcher.php, line 89
Class
- Matcher
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\Framework\MockObjectCode
public function invoked(Invocation $invocation) : mixed {
if ($this->methodNameRule === null) {
throw new MethodNameNotConfiguredException();
}
if ($this->afterMatchBuilderId !== null) {
$matcher = $invocation->object()
->__phpunit_getInvocationHandler()
->lookupMatcher($this->afterMatchBuilderId);
if (!$matcher) {
throw new MatchBuilderNotFoundException($this->afterMatchBuilderId);
}
}
$this->invocationRule
->invoked($invocation);
try {
$this->parametersRule?->apply($invocation);
} catch (ExpectationFailedException $e) {
throw new ExpectationFailedException(sprintf("Expectation failed for %s when %s\n%s", $this->methodNameRule
->toString(), $this->invocationRule
->toString(), $e->getMessage()), $e->getComparisonFailure());
}
if ($this->stub) {
return $this->stub
->invoke($invocation);
}
return $invocation->generateReturnValue();
}