function InvocationMocker::method
Return value
$this
Throws
MethodCannotBeConfiguredException
MethodNameAlreadyConfiguredException
Overrides MethodNameMatch::method
File
-
vendor/
phpunit/ phpunit/ src/ Framework/ MockObject/ Runtime/ Builder/ InvocationMocker.php, line 249
Class
- InvocationMocker
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\Framework\MockObject\BuilderCode
public function method(Constraint|string $constraint) : self {
if ($this->matcher
->hasMethodNameRule()) {
throw new MethodNameAlreadyConfiguredException();
}
if (is_string($constraint)) {
$this->configurableMethodNames ??= array_flip(array_map(static fn(ConfigurableMethod $configurable) => strtolower($configurable->name()), $this->configurableMethods));
if (!array_key_exists(strtolower($constraint), $this->configurableMethodNames)) {
throw new MethodCannotBeConfiguredException($constraint);
}
}
$this->matcher
->setMethodNameRule(new Rule\MethodName($constraint));
return $this;
}