src/Stub/Answer/Builder/GeneratorAnswerBuilder.php
public function throws(...$exceptions): Stub
    {
        if (empty($exceptions)) {
            $exceptions = [new Exception()];
        }

        $exception = $exceptions[0];
        $argumentCount = count($exceptions);
        $copies = [];

        for ($i = 1; $i < $argumentCount; ++$i) {
            $copies[$i] = clone $this;
        }

        if (is_string($exception)) {
            $exception = new Exception($exception);
        } elseif ($exception instanceof InstanceHandle) {
            $exception = $exception->get();
        }

        $this->exception = $exception;

        for ($i = 1; $i < $argumentCount; ++$i) {
            $this->stub
                ->doesWith($copies[$i]->answer(), [], true, true, false);

            $copies[$i]->throws($exceptions[$i]);
        }

        return $this->stub;
    }
public function throws(...$exceptions): Stub
    {
        if (empty($exceptions)) {
            $exceptions = [new Exception()];
        }

        $exception = $exceptions[0];
        $argumentCount = count($exceptions);
        $copies = [];

        for ($i = 1; $i < $argumentCount; ++$i) {
            $copies[$i] = clone $this;
        }

        if (is_string($exception)) {
            $exception = new Exception($exception);
        } elseif ($exception instanceof InstanceHandle) {
            $exception = $exception->get();
        }

        $this->exception = $exception;

        for ($i = 1; $i < $argumentCount; ++$i) {
            $this->stub
                ->doesWith($copies[$i]->answer(), [], true, true, false);

            $copies[$i]->throws($exceptions[$i]);
        }

        return $this->stub;
    }
public function throws ( ... $ exceptions ) : Stub { if ( empty ( $ exceptions ) ) { $ exceptions = [ new Exception ( ) ] ; } $ exception = $ exceptions [ 0 ] ; $ argumentCount = count ( $ exceptions ) ; $ copies = [ ] ; for ( $ i = 1 ; $ i < $ argumentCount ; ++ $ i ) { $ copies [ $ i ] = clone $ this ; } if ( is_string ( $ exception ) ) { $ exception = new Exception ( $ exception ) ; } elseif ( $ exception instanceof InstanceHandle ) { $ exception = $ exception -> get ( ) ; } $ this -> exception = $ exception ; for ( $ i = 1 ; $ i < $ argumentCount ; ++ $ i ) { $ this -> stub -> doesWith ( $ copies [ $ i ] -> answer ( ) , [ ] , true , true , false ) ; $ copies [ $ i ] -> throws ( $ exceptions [ $ i ] ) ; } return $ this -> stub ; }
End the generator by throwing an exception.

Calling this method with no arguments is equivalent to calling it with a
single argument of `null`.

@param Throwable|string|null ...$exceptions The exceptions, or messages, or nulls to throw generic exceptions.

@return Stub The stub.
End the generator by throwing an exception .