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

Breadcrumb

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

function InvocationHandler::invoke

Throws

\PHPUnit\Framework\MockObject\Exception

Exception

File

vendor/phpunit/phpunit/src/Framework/MockObject/Runtime/InvocationHandler.php, line 100

Class

InvocationHandler
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Framework\MockObject

Code

public function invoke(Invocation $invocation) : mixed {
    $exception = null;
    $hasReturnValue = false;
    $returnValue = null;
    foreach ($this->matchers as $match) {
        try {
            if ($match->matches($invocation)) {
                $value = $match->invoked($invocation);
                if (!$hasReturnValue) {
                    $returnValue = $value;
                    $hasReturnValue = true;
                }
            }
        } catch (Exception $e) {
            $exception = $e;
        }
    }
    if ($exception !== null) {
        throw $exception;
    }
    if ($hasReturnValue) {
        return $returnValue;
    }
    if (!$this->returnValueGeneration) {
        if (strtolower($invocation->methodName()) === '__tostring') {
            return '';
        }
        throw new ReturnValueNotConfiguredException($invocation);
    }
    return $invocation->generateReturnValue();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal