execute command by coroutine

@param mixed $class
@param string $method
@param bool   $server
@param array  $bindParams
5741
private function executeCommandByCoroutine($class, string $method, bool $server, $bindParams)
    {
        Coroutine::create(function () use ($class, $method, $server, $bindParams) {
            $this->beforeCommand(\get_parent_class($class), $method, $server);
            PhpHelper::call([$class, $method], $bindParams);
            $this->afterCommand($method, $server);
        });
    }
807917
public function callAction($method, array $parameters = [])
    {
        $isAjax = app()->make('request')->ajax();

        $method = $this->checkAjaxMethod($method, $isAjax);
        $parameters = $this->checkParametersResolving($method, $parameters);

        return parent::callAction($method, $parameters);
    }
1373376
public function byClassMethod($class, $method)
    {
        $this->controller = new $class();
        $this->controller = is_object($class) ? $class : new $class();
        if ($this->hasContainer() && method_exists($this->controller, 'raikiri'))
            $this->controller->setContainer($this->raikiri());

        $this->action = function() use($method)
        {
            $args = func_get_args();
            return call_user_func_array([$this->controller, $method], $args);
        };
    }
43442
protected function present($command, \ReflectionMethod $method, \ReflectionClass $class) {
        if ($method->isStatic())
            return;
        if ('action' !== substr($method->getName(), 0, 6))
            return;

        $params = $method->getParameters();

        echo $this->getRunPath() . ' ' . $command . " " . lcfirst(substr($method->getName(), 6));

        foreach ($params as $p)
            echo $this->paramDetails($p);
        if ($class->getDocComment()) {
            echo "\n" . $class->getDocComment();
        }
        echo "\n\n";
    }
1039783
public static function bcRun($class, $method, array $params, $implementation, array $filters) {
		$implementation = static::_bcImplementation($class, $method, $params, $implementation);
		$ids = static::_ids($class, $method);

		foreach ($ids as $id) {
			if (isset(static::$_filters[$id])) {
				$filters = array_merge(static::$_filters[$id], $filters);
			}
		}
		return new Chain(compact('class', 'method', 'filters'));
	}
600083
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
  {
    # Copied from Guzzles ::fromGlobals(), but we need to support the $server array as
    # paramter, so we use that instead of the $_SERVER array guzzle uses by default

    $method = isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET';
    $headers = \function_exists('getallheaders') ? \getallheaders() : [];
    $uri = $uri;
    $body = new LazyOpenStream('php://input', 'r+');
    $protocol = isset($server['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $server['SERVER_PROTOCOL']) : '1.1';

    $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $server);

    \logger()->debug('Created PSR-7 ServerRequest("'.$method.'","'.$url.'") (Guzzle)');

    return $serverRequest
        ->withCookieParams($_COOKIE)
        ->withQueryParams($_GET)
        ->withParsedBody($_POST)
        ->withUploadedFiles(ServerRequest::normalizeFiles($_FILES));
  }
400218
private function executeFacebookRequest($method, $endpoint, array $parameters = [], $token = null)
    {
        if (is_callable($this->logCallback)) {
            //used only for debugging:
            call_user_func($this->logCallback, 'Facebook API request', func_get_args());
        }

        if (!$token) {
            $token = $this->appToken;
        }

        switch ($method) {
            case 'GET':
                $response = $this->fb->get($endpoint, $token);
                break;
            case 'POST':
                $response = $this->fb->post($endpoint, $parameters, $token);
                break;
            case 'DELETE':
                $response = $this->fb->delete($endpoint, $parameters, $token);
                break;
            default:
                throw new \Exception("Facebook driver exception, please add support for method: " . $method);
                break;
        }

        if (is_callable($this->logCallback)) {
            call_user_func($this->logCallback, 'Facebook API response', $response->getDecodedBody());
        }

        return $response;
    }
345744
public function bind(Server $server)
    {
        if ($this->isBound()) {
            throw new LogicException('Process can be bound to server only once.');
        }

        $this->server = $server;

        $this->dispatchEvent('Bind', $server, $this);
    }
829968
static function exec( $method, &$result )
    {
        $ini = eZINI::instance( 'ezmultiupload.ini' );
        $handlers = $ini->variable( 'MultiUploadSettings', 'MultiuploadHandlers' );

        if ( !$handlers )
            return false;

        foreach ( $handlers as $hanlder )
        {
            if ( !call_user_func( array( $hanlder, $method ), $result ) )
                eZDebug::writeWarning( 'Multiupload handler implementation not found' );
        }

        return true;
    }
1166742
protected function handle_request( $method, $request_method, array $arguments = [] ) {
		if ( empty( $method ) || 'page' === $method ) {
			$page = max( ( isset( $arguments[0] ) ? intval( $arguments[0] ) : 1 ), 1 );
			$this->pager( $page );
			exit;
		} else {
			// Call method if exists.
			if ( $this->invoke( $method, $request_method, $arguments ) ) {
				exit;
			} else {
				$this->method_not_found();
			}
		}
	}
1182524
public function listen(Server $server, SwoolePort $swoolePort = null)
    {
        if ($this->isBound()) {
            throw new LogicException('The server socket can be bound to server only once.');
        }

        if ($swoolePort == null) {
            // If the passed Swoole port is null, that means we are calling this
            // method directly, so here we need to call the server method "listen"
            // to do the actual binding.
            return $server->listen($this);
        }

        $this->server = $server;
        $this->swoolePort = $swoolePort;

        $this->swoolePort->set($this->options);

        $this->registerEventCallbacks($this->serverSocketEvents);

        $this->dispatchEvent('Bind', $server, $this);
    }
591590
public function executeRequest($method, $url, $token, $body = null)
    {
        $options = [];
        if ($body) {
            $options['body'] = json_encode($body);
            $options['headers']['Content-Type'] = 'application/json';
        }

        $request = $this->getAuthenticatedRequest($method, $this->apiDomain.'/'.$this->version.$url, $token, $options);

        return $this->getParsedResponse($request);
    }
1006897
public function invoke($object, string $method, array $parameters)
    {
        $handler    = $object;
        $reflection = new \ReflectionMethod($handler, $method);

        if ($reflection->getNumberOfRequiredParameters() > count($parameters)) {
            throw new InvalidParamsException('Expected ' . $reflection->getNumberOfRequiredParameters() . ' parameters');
        }

        $formalParameters = $reflection->getParameters();
        $actualParameters = $this->prepareActualParameters($formalParameters, $parameters);

        try {
            $result = $reflection->invokeArgs($handler, $actualParameters);
        } catch (\Exception $exception) {
            throw new ServerErrorException($exception->getMessage(), $exception->getCode());
        }

        return $this->castResult($result);
    }
1023681
protected function classMethod(&$class = NULL, &$method = NULL, $command)
    {
        $commandEx = explode(':', $command);
        $class     = $commandEx[0];
        $method    = $commandEx[1] ?? NULL;
    }
76965
public function handle(
        ServerRequestInterface $request, ResponseInterface $response
    )
    {
        $route = $this->getMatcher()->match($request);
        $request = $request->withAttribute('route', $route);
        return $this->executeNext($request, $response);
    }
906283
private function exec($url, $data = '', $method = 'post', $header = [])
    {
        $res = false;
        $this->try = 0;
        $this->result = '';
        $this->action('start');

        while ($this->try < $this->tryMax) {
            $this->try++;
            $res = $this->realExec($url, $data, $method, $header);
            if ($res) {
                break;
            }
        }

        $this->action('stop');
        return $res;
    }
1215426
public function command($method, array $parameters = [])
    {
        $start = microtime(true);

        $result = $this->client->{$method}(...$parameters);

        $time = round((microtime(true) - $start) * 1000, 2);

        if (isset($this->events)) {
            $this->event(new CommandExecuted($method, $parameters, $time, $this));
        }

        return $result;
    }