lib/Assertion.php
function throw(string $className = ''): self {
    if (!is_callable($this->target)) throw new \BadMethodCallException('The function target is not callable.');

    $exception = null;
    try { call_user_func($this->target); }
    catch (\Throwable $e) { $exception = $e; }

    $constraint = logicalNot(isNull());
    return $this->expect($exception, mb_strlen($className) ? logicalAnd($constraint, isInstanceOf($className)) : $constraint);
  }
function throw(string $className = ''): self {
    if (!is_callable($this->target)) throw new \BadMethodCallException('The function target is not callable.');

    $exception = null;
    try { call_user_func($this->target); }
    catch (\Throwable $e) { $exception = $e; }

    $constraint = logicalNot(isNull());
    return $this->expect($exception, mb_strlen($className) ? logicalAnd($constraint, isInstanceOf($className)) : $constraint);
  }
Reports an error if the function target does not throw a given exception.
@param string $className The class name of the exception.
@return self This instance.
@throws \BadMethodCallException The function target is not callable.