gRPC requires metadata keys to be as a string. Also, the PHP gRPC library expects them in an array.

@param callable $callback
@return Response
779135
public function call(callable $callback): Response
    {
        foreach (self::METADATA_KEYS as $incomingKey => $metadataKey) {
            if (array_key_exists($incomingKey, $_SERVER)) {
                $this->metadata[$metadataKey] = ['' . $_SERVER[$incomingKey]];
            }
            if (array_key_exists($incomingKey, $_REQUEST)) {
                $this->metadata[$metadataKey] = ['' . $_REQUEST[$incomingKey]];
            }
        }
        $response = $callback();
        return $response;
    }
376261
public function callbackLogs($key, $callback)
    {
        $p = compact('key', 'callback');
        $q = http_build_query($p);

        curl_setopt($this->ch, CURLOPT_POST, false);
        curl_setopt($this->ch, CURLOPT_URL, static::URL.'/callback_log?'.$q);

        if (($resp = curl_exec($this->ch)) === false) {
            throw new HttpError(curl_error($this->ch));
        }

        if (($data = json_decode($resp, true)) === NULL) {
            throw new Error("Unable to decode JSON response from Blockchain: $resp");
        }

        $info = curl_getinfo($this->ch);

        if ($info['http_code'] == 200) {
            return array_map([$this, 'createCallbackLogEntry'], (array) $data);
        }

        throw new Error(implode(', ', $data));
    }
928730
protected function normalizeCallback($callback)
	{
		// Normalize ['foo', 'bar'] to 'foo::bar'
		if (is_array($callback) && is_string($callback[0]))
		{
			$callback = $callback[0] . '::' . $callback[1];
		}

		// Normalize '\\foo' to 'foo' and '\\foo::bar' to 'foo::bar'
		if (is_string($callback))
		{
			$callback = ltrim($callback, '\\');
		}

		return $callback;
	}
633015
public function capture_append( $key, $callback ) 
	{
		return $this->set( $key, $this->get( $key, '' ).CCStr::capture( $callback, $this ) );
	}
358315
protected function get_callback_name( $callback, int $args ): string {

		switch ( gettype( $callback ) ) {
			case 'object':
				$callback = $this->get_class_name( $callback );
				break;

			case 'array':
				$class    = is_string( $callback[0] )
					? $callback[0] . '::'
					: $this->get_class_name( $callback[0] ) . '->';
				$callback = $class . $callback[1];
				break;
		}

		$callback .= ( 1 === $args ) ? '' : "({$args})";

		return $callback;
	}
130680
public static function callback($key = null, $callback)
    {
        // Get parameters for callback
        $callbackParams = func_get_args();
        unset($callbackParams[0], $callbackParams[1]);
        $callbackParams = array_values($callbackParams);

        // Get key if no key is given
        if (is_null($key)) {
            if (is_string($callback)) {
                $key = $callback;
            } elseif (is_array($callback)) {
                $keyArr = [];
                foreach ($callback as $k => $v) {
                    if (is_string($v)) {
                        $keyArr[] = $v;
                    } elseif (is_object($v)) {
                        $keyArr[] = get_class($v);
                    }
                }

                $key = implode('', $keyArr);
                if (count($keyArr) > 1) {
                    $method = array_pop($keyArr);
                    $key    = implode('/', $keyArr);
                    $key    .= '::' . $method;
                }

                unset($keyArr, $method);
            } elseif (is_object($callback) && $callback instanceof \Closure) {
                $key = 'closure';
            }
            $key = 'callback: ' . $key;
        }

        // Set default return value
        $returnValue = true;

        // Set error handler, to convert errors to exceptions
        set_error_handler(function ($errno, $errstr, $errfile, $errline, array $errcontext) {
            throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
        });

        try {
            // Start output buffer to capture any output
            ob_start();

            // Start profiler
            self::start($key);

            // Execute callback, and get result
            $callbackResult = call_user_func_array($callback, $callbackParams);

            // Stop profiler
            self::stop($key);

            // Get and clean output buffer
            $callbackOutput = ob_get_clean();
        } catch (\ErrorException $callbackException) {
            // Stop and clean output buffer
            ob_end_clean();

            // Show error message
            self::output('Invalid callback sent to Timer::callback: ' . str_replace('callback: ', '', $key));

            // Clear the item from the collection
            unset(self::$collection[$key]);

            // Clear callback result and output
            unset($callbackResult, $callbackOutput);

            // Set return value to false
            $returnValue = false;
        }

        // Restore error handler
        restore_error_handler();

        // Return result, output or true
        return (isset($callbackResult) ? $callbackResult : (!empty($callbackOutput) ? $callbackOutput : $returnValue));
    }
888455
public function addTokenCallback($callback)
    {
        $token                   = $this->token;
        $this->callBacks[$token] = $callback;
        $this->token++;
        if ($this->token >= self::MAX_TOKEN) {
            $this->token = 0;
        }

        return $token;
    }
407879
public function map(callable $callback)
	{
		$keys = array_keys($this->members);
		$members = array_map($callback, $this->members, $keys);
		return new static(array_combine($keys, $members));
	}
1219251
public function map($callback)
    {
        if (!is_callable($callback)) {
            throw new InvalidArgumentException('Callback has to be a valid callable, '.gettype($callback).' given.');
        }

        for ($i = 0; $this->checkIfLineNumberIsValid($i, false); $i++) {
            $this->setCurrentLineNumber($i);
            call_user_func($callback, $this->getLine($i), $i, $this);
        }
    }
514679
public function each($callback)
    {
        foreach ($this->_data as $key => $val) {
            $this->_data[$key] = $callback($val, $key, $this);
        }
        return $this;
    }
1130173
protected static function controllerCallback($callback)
    {
        $datas      = Structure::data($callback);
        $function   = $datas['function'];
        $parameters = $datas['parameters'];
        $class      = $datas['namespace'] . $datas['page'];

        return function() use($class, $function, $parameters)
        { 
            (new $class)->$function(...$parameters); 
        };
    }
937584
public function extract(callable $callback = null)
    {

        if ($callback === null) {
            $result = $this->result->serialize();
        }
        else {
            $result = $callback($this->result->serialize());
        }

        return $result;

    }
132087
public function mapWithKeys(callable $callback): CollectionInterface
    {
        return $this->wrap(function (Iterator $data) use ($callback) {
            foreach ($data as $key => $value) {
                /** @var iterable $result */
                $result = $callback($value, $key);

                foreach ($result as $resultKey => $resultValue) {
                    yield $resultKey => $resultValue;
                }
            }
        });
    }
1193242
public function extract(callable $callback = null)
    {
        $this->response = Di::getDefault()->get('response');

        if ($callback === null) {
            $this->response->setContent(json_encode($this->result->toArray()));
        }

        else {
            $this->response->setContent($callback(
                json_encode($this->result->toArray())
            ));
        }

        $this->response->send();

    }
824325
public function capture( $key, $callback ) 
	{
		return $this->set( $key, CCStr::capture( $callback, $this ) );
	}
670627
private static function execCallback(array $callback)
    {
        if (count($callback) >= 2 && count($callback) <= 3) {
            try {
                if (count($callback) == 2) {
                    return call_user_func_array(array($callback[0], $callback[1]));
                }
                if (count($callback) == 3) {
                    return call_user_func_array(array($callback[0], $callback[1]), (array) $callback[2]);
                }
            } catch (\Exception $e) {
                unset($e);
            }
        }
    }
1153479
public function map(callable $callback): Collection
    {
        $keys = array_keys($this->items);
        $items = array_map($callback, $this->items, $keys);

        return new static(array_combine($keys, $items));
    }