function MethodProphecy::willYield
Parameters
array<mixed> $items:
mixed $return:
Return value
$this
Throws
\Prophecy\Exception\InvalidArgumentException
File
-
vendor/
phpspec/ prophecy/ src/ Prophecy/ Prophecy/ MethodProphecy.php, line 273
Class
- MethodProphecy
- Method prophecy.
Namespace
Prophecy\ProphecyCode
public function willYield($items, $return = null) {
if ($this->voidReturnType) {
throw new MethodProphecyException("The method \"{$this->methodName}\" has a void return type, and so cannot yield anything", $this);
}
if (!is_array($items)) {
throw new InvalidArgumentException(sprintf('Expected array, but got %s.', gettype($items)));
}
$generator = function () use ($items, $return) {
yield from $items;
return $return;
};
return $this->will($generator);
}