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

Breadcrumb

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

function Invoker::invoke

Throws

Throwable

File

vendor/phpunit/php-invoker/src/Invoker.php, line 28

Class

Invoker

Namespace

SebastianBergmann\Invoker

Code

public function invoke(callable $callable, array $arguments, int $timeout) : mixed {
    if (!$this->canInvokeWithTimeout()) {
        throw new ProcessControlExtensionNotLoadedException('The pcntl (process control) extension for PHP is required');
    }
    pcntl_signal(SIGALRM, function () : void {
        throw new TimeoutException(sprintf('Execution aborted after %d second%s', $this->timeout, $this->timeout === 1 ? '' : 's'));
    }, true);
    $this->timeout = $timeout;
    pcntl_async_signals(true);
    pcntl_alarm($timeout);
    try {
        return call_user_func_array($callable, $arguments);
    } finally {
        pcntl_alarm(0);
    }
}
RSS feed
Powered by Drupal