function LazyDouble::addInterface
Tells doubler to implement specific interface with double.
@template U of object @phpstan-param class-string<U>|ReflectionClass<U> $interface @phpstan-this-out static<T&U>
Parameters
class-string|ReflectionClass<object> $interface:
Return value
void
Throws
File
-
vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ LazyDouble.php, line 99
Class
- LazyDouble
- Lazy double. Gives simple interface to describe double before creating it.
Namespace
Prophecy\DoublerCode
public function addInterface($interface) {
if (null !== $this->double) {
throw new DoubleException('Can not implement interface with already instantiated double.');
}
if (!$interface instanceof ReflectionClass) {
if (!interface_exists($interface)) {
throw new InterfaceNotFoundException(sprintf('Interface %s not found.', $interface), $interface);
}
$interface = new ReflectionClass($interface);
}
$this->interfaces[] = $interface;
}