Actual publish/subscribe context initializer method.

@param array $options  Options for the context.
@param mixed $callable Optional callable used to execute the context.

@return PubSubConsumer|null
18534
protected function createPubSub(array $options = null, $callable = null)
    {
        $pubsub = new PubSubConsumer($this, $options);

        if (!isset($callable)) {
            return $pubsub;
        }

        foreach ($pubsub as $message) {
            if (call_user_func($callable, $pubsub, $message) === false) {
                $pubsub->stop();
            }
        }
    }
111967
public function map($callable)
    {
        if (!$this->isCallable($callable)) {
            throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [
                '$callable',
                'a callable function or method'
            ]);
        }

        $this->val(array_map($callable, $this->val()));

        return $this;
    }
947926
public function add($callable)
    {
        $callable = $this->resolveCallable($callable);
        if ($callable instanceof Closure) {
            $callable = $callable->bindTo($this->container);
        }

        $this->middleware[] = $callable;

        return $this;
    }
957258
public function execute($callable = null)
    {
        if ($callable && !is_callable($callable)) {
            throw new \InvalidArgumentException('The argument must be a callable object.');
        }

        $exception = null;
        $this->setRunning(true);

        try {
            if ($callable) {
                call_user_func($callable, $this);
            }

            $this->flushPipeline();
        } catch (\Exception $exception) {
            // NOOP
        }

        $this->setRunning(false);

        if ($exception) {
            throw $exception;
        }

        return $this->responses;
    }
76002
protected function createPipeline(array $options = null, $callable = null)
    {
        if (isset($options['atomic']) && $options['atomic']) {
            $class = 'Predis\Pipeline\Atomic';
        } elseif (isset($options['fire-and-forget']) && $options['fire-and-forget']) {
            $class = 'Predis\Pipeline\FireAndForget';
        } else {
            $class = 'Predis\Pipeline\Pipeline';
        }

        /*
         * @var ClientContextInterface
         */
        $pipeline = new $class($this);

        if (isset($callable)) {
            return $pipeline->execute($callable);
        }

        return $pipeline;
    }
661089
protected function callFast(callable $callable, array $params = [])
    {

        // call_user_func_array seems to be slow
        switch (count($params)) {
            case 1:
                return call_user_func($callable, $params[0]);
            case 2:
                return call_user_func($callable, $params[0], $params[1]);
            case 3:
                return call_user_func($callable, $params[0], $params[1], $params[2]);
            case 4:
                return call_user_func($callable, $params[0], $params[1], $params[2], $params[3]);
            default:
                return call_user_func_array($callable, $params);
        }
    }
1298380
public function rightJoin($table, callable $callable)
    {
        $table = $this->getPrefix().$table;

        if (is_null($this->join)) {
            $this->join = 'right join `'.$table.'`';

            if (is_callable($callable)) {
                $callable($this);
            }

            return $this;
        }

        if (!preg_match('/^(inner|left)\sjoin\s.*/', $this->join)) {
            $this->join .= ', `'.$table.'`';

            if (is_callable($callable)) {
                $callable($this);
            }

            return $this;
        }

        throw new QueryBuilderException(
            'The inner join clause is already initialized.',
            E_ERROR
        );
    }
747038
public function setSubscriptionOptionMode($subscriptionOptionMode)
    {
        if (!in_array($subscriptionOptionMode, $this->subscriptionOptionModes)) {
            throw new InvalidArgumentException('Unsupported subscription option mode.');
        }
        return $this->setData(self::SUBSCRIPTION_OPTION_MODE, $subscriptionOptionMode);
    }
969744
protected function initArrayCallbackOption($options)
    {
        if (!isset($options['callback']) && !isset($options['groups']) && \is_callable($options)) {
            $options = ['callback' => $options];
        }

        return $options;
    }
341413
public function createSubscriber($mode, $dsn = null, $subscribe = '', $options = array())
    {
        $options[ZMQ::SOCKOPT_SUBSCRIBE] = $subscribe;

        return $this->createSocket(ZMQ::SOCKET_SUB, $mode, $dsn, $options);
    }
434096
public function resolveArguments($callable, array $context) {
        $resolve_arg = $this->resolve_arg;

        $rf = $this->callableToReflectionFunctionAbstract($callable);

        $args = [];
        foreach ($rf->getParameters() as $i => $arg_meta) {
            $arg = $resolve_arg($arg_meta, $context);
            if (!count($arg) && $arg_meta->isOptional()) {
                continue;
            } else if (!count($arg)) {
                throw new Exception\ResolutionException($arg_meta);
            }

            $args[] = $arg[0];
        }

        return $args;
    }
1371970
public function addRuleAnnotation(UdpRouteAnnotation $annotation, $callable, $options = [])
    {
        $this->rules[$this->hashKey($annotation)] = array_merge([
            'annotation'=> $annotation,
            'callable'  => $callable,
        ], $options);
    }
206916
protected function resolveCallable($callable)
    {
        if (!$this->container instanceof ContainerInterface) {
            return $callable;
        }

        /** @var CallableResolverInterface $resolver */
        $resolver = $this->container->get('callableResolver');

        return $resolver->resolve($callable);
    }
140920
public function addCallable(string $name, callable $callable): self
    {
        $this->container[$name] = $callable;
        array_unshift($this->middleware, $name);

        return $this;
    }
180798
public function call(callable $callable, array $parameters = [])
	{
		if(is_array($callable))
		{
			$reflection = new ReflectionMethod($callable[0], $callable[1]);
		}
		else
		{
			$reflection = new ReflectionFunction($callable);
		}

		return $callable(...$this->resolveParameters($reflection->getParameters(), $parameters));
	}
436729
private function genericSubscribeInit($subscribeAction)
    {
        if (isset($this->options[$subscribeAction])) {
            $this->$subscribeAction($this->options[$subscribeAction]);
        }
    }
498927
private function _publishExtensionClientInit()
    {
        $extensionOptionsJson = json_encode(array(
            'hashMethod'                => is_string($this->hashMethod) ? $this->hashMethod : 'php callback function',
            'resourceTypes'             => $this->resourceTypes,
            'enableLog'                 => $this->enableLog,
            'activateOnAllPages'        => $this->activateOnAllPages,
            'alwaysReloadableResources' => $this->alwaysReloadableResources,
            'jsGlobalObjPublicPath'     => $this->jsGlobalObjPublicPath(),
            'clientVarName'             => $this->clientVarName,
        ));
        $this->_publishExtensionJs('%extensionObject%.initExtension(%optionsJson%); ', array(
            '%extensionObject%' => self::JS_GLOBAL_OBJ_PRIVATE_PATH,
            '%optionsJson%'     => $extensionOptionsJson,
        ));
    }