发送异步的HTTP请求

@param callable $callback 请求响应的回调函数
329109
public function send($callback)
    {
        switch ($this->method) {
            case 'POST':
                $this->client->post($this->path, $this->data, $callback);
                break;
            case 'GET':
                $this->client->get($this->path, $this->data, $callback);
                break;
            case 'EXECUTE':
                if (!empty($this->data)) {
                    $this->client->setData($this->data);
                }
                $this->client->execute($this->path, $callback);
                break;
        }
    }
1287937
public function tryFlatTransaction(callable $callback)
    {
        $autoStartTransaction = $this->inTransaction() === false;

        // If we're starting a transaction, we don't need to catch here
        if ($autoStartTransaction) {
            $this->beginTransaction();
        }
        try {
            /**
            * @var string|int|bool|float|null|array|object|resource $out
            */
            $out = $callback($this);
            // If we started the transaction, we should commit here
            if ($autoStartTransaction) {
                $this->commit();
            }

            return $out;
        } catch (Throwable $e) {
            // If we started the transaction, we should cleanup here
            if ($autoStartTransaction) {
                $this->rollBack();
            }

            throw $e;
        }
    }
871793
public function registerCallback(callable $callback)
    {
        $this->pipeline
            ->pipe($callback)
            ->process($this->config);

        return $this;
    }
250231
public function setUserCallback (callable $callback)
	{
		//$this->usercallback = $callback;

		if (count ($this->usercallback) > 0)
			throw new InvalidParameter ("A usercallback was already set. Use addUserCallback to add multiple callbacks");

		$this->addUserCallback ('default', $callback);

		return $this;
	}
158890
protected function wrapCallback(callable $callback)
    {
        return function ($response, $connection, $command) use ($callback) {
            if ($command && !$response instanceof ResponseInterface) {
                $response = $command->parseResponse($response);
            }

            \call_user_func($callback, $response, $this, $command);
        };
    }
86190
public function mapSpread(callable $callback)
    {
        return $this->map(function ($chunk, $key) use ($callback) {
            $chunk[] = $key;

            return $callback(...$chunk);
        });
    }
473766
protected function setCallback($callback) {
		if (!is_callable($callback)) {
			throw new InvalidCallbackException('Invalid callback');
		}

		$this->reflection_parameter =  $this
			     ->getCallbackReflection($callback)
			     ->getParameters()
		;
		$this->callback = $callback;

		return $this;
	}
1165300
public function send($url, $method = 'GET', $data = null, callable $callback = null)
    {
        $this->curl($url);
        $this->setDefaultOptions();

        if (is_array($this->options))
        {
            if (count($this->options) > 0)
            {
                foreach ($this->options as $key => $value)
                {
                    $this->setOption($key, $value);
                }
            }
        }

        if ($method !== self::GET)
        {
            $this->method($method);
        }

        if ($method === self::POST || $method === self::PUT || $method === self::DELETE)
        {
            $this->setOption(CURLOPT_POSTFIELDS, $data);
        }

        $response = $this->execute();

        if (!$response)
        {
            $this->error();
        }

        $this->getInfo();
        $this->close();

        if ( is_callable($callback) )
        {
            $callback($this->response, $this->info, $this->errors);
        }

        return $response;
    }
1110130
public function map(callable $callback = null)
	{
		return $callback ? array_map($callback, $this->list) : $this->list;
	}
409412
public function each(callable $callback)
    {
        foreach ($this->items as $key => $item) {
            if ($callback($item, $key) === false) {
                break;
            }
        }

        return $this;
    }
167270
public function error(callable $callback)
    {
        if ($callback instanceof Closure) {
            $callback = $callback->bindTo($this, get_class($this));
        }

        $this->getErrorProcessor()->register($callback);
        return $this;
    }
295897
public static function error(callable $callback = null){
        $callback
          ? is_callable($callback) && static::$error = $callback
          : static::$error && call_user_func(static::$error);
    }
86744
protected function checkAndReturnCallable($callback)
    {
        if (is_string($callback)) {
            return function ($app) use ($callback) {
                return $app($callback);
            };
        }

        if (!is_callable($callback)) {
            $type = is_object($callback) ? get_class($callback) : gettype($callback);
            throw new InvalidArgumentException("Passed argument of type $type is not callable");
        }

        return $callback;
    }
114474
public function setApiCallback($callback)
    {

        if (empty($callback)) {
            $this->apiResponseCallback = false;
            return;
        }

        if (!is_callable($callback)) {
            throw new \Exception('Callback should be a function or false.');
        }

        $this->apiResponseCallback = $callback;
    }
1013057
public function eachSpread(callable $callback)
    {
        return $this->each(function ($chunk, $key) use ($callback) {
            $chunk[] = $key;

            return $callback(...$chunk);
        });
    }
48133
public function setCallback($callback = null)
    {
        if (!is_null($callback) && !is_callable($callback)) {
            throw new Exception("callback must be of type callable or null");
        }

        $this->callback = $callback;

        return $this;
    }
791099
public function wrap_callback(callable $callback, array $args=[]) {
		ob_start();
		foreach (self::$override_args as $key => $val)
			$args[$key] = $val;
		$callback($args);
		self::$body_raw = ob_get_clean();
		self::$body = json_decode(self::$body_raw, true);
		if (self::$body) {
			self::$errno = self::$body['errno'];
			self::$data = self::$body['data'];
		} else {
			self::$errno = 0;
			self::$data = [];
		}
	}