Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MethodProphecy.php

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\Prophecy

Code

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);
}
RSS feed
Powered by Drupal