@param $callback

@return mixed|null

@throws \Exception
491790
public function tryUntil($callback)
    {
        try {
            return call_user_func_array($this->process, $this->args);
        } catch (\Exception $e) {
            if (in_array(get_class($e), $this->allowedExceptions)) {
                throw $e;
            }
        }

        $this->logger->warning(sprintf('[%s] Waiting until callback return a success', $this->logInfos['callable']));

        $startTime = time();
        $retry = 1;

        for (;;) {
            if ($callback instanceof YoloInterface) {
                $available = $callback->isAvailable();
            } else {
                $available = call_user_func($callback);
            }

            if (true === $available) {
                try {
                    return call_user_func_array($this->process, $this->args);
                } catch (\Exception $e) {
                    $this->logger->warning(sprintf('[%s] Can\'t perform action [%s/%s]', $this->logInfos['callable'], $retry, $this->maxRetry));

                    if (in_array(get_class($e), $this->allowedExceptions)) {
                        throw $e;
                    }

                    ++$retry;
                }

                if ($retry >= $this->maxRetry) {
                    $this->logger->error(sprintf('[%s] retry has failed, aborting [%s/%s]', $this->logInfos['callable'], $retry, $this->maxRetry));

                    $retryException = new YoloException('', 0, $e);
                    $retryException->setRetry($this->maxRetry);
                    $retryException->setTimeout($this->timeout);
                    throw $retryException;
                }
            } else {
                $this->logger->warning(sprintf('[%s] Can\'t perform action, waiting next tick', $this->logInfos['callable']));
            }

            if ($this->timeout > 0 && (time() - $startTime) >= $this->timeout) {
                $retryException = new YoloException('Timed out');
                $retryException->setRetry($this->maxRetry);
                $retryException->setTimeout($this->timeout);

                throw $retryException;
            }

            sleep(1);
        }
    }
1211746
public function then(\Closure $callback)
    {
        if ($this->ready) {
            return null;
        }

        $this->ready = true;

        if (!$this->checkDomain() || !$this->checkPath() || !$this->checkSecurity()) {
            return null;
        }

        $oNS = parent::$prefixNS;
        $oPP = parent::$prefixPath;

        if ($this->ns) {
            parent::$prefixNS = $this->ns;
        }

        if ($this->path) {
            parent::$prefixPath = rtrim($this->currentPrefixPath, '/');
        }

        call_user_func_array($callback, $this->arguments);

        parent::$prefixNS = $oNS;
        parent::$prefixPath = $oPP;
    }
826233
public function findIndex(callable $callback)
    {
        $array = $this->getArrayCopy();
        foreach ($array as $key => $value) {
            if ($callback($value, $key, $array) === true) {
                return $key;
            }
        }

        return -1;
    }
1195594
private function _catch($callback) {
        if ($this->state === self::REJECTED) {
            $this->value = $callback($this->value);
        }
        return $this;
    }
244129
protected function handleCallback($callback, array $args = [])
    {
        $response = null;

        // Check if $callback is a closure.
        if ($callback instanceof \Closure || is_array($callback)) {
            $response = call_user_func($callback, $args);
        } elseif (is_string($callback)) {
            if (false !== strpos($callback, '@') || class_exists($callback)) {
                // We use a "ClassName@method" syntax.
                // Let's get a class instance and call its method.
                $callbackArray = $this->handleClassCallback($callback);
                $response = call_user_func($callbackArray, $args);
            } else {
                // Used as a classic callback function.
                $response = call_user_func($callback, $args);
            }
        }

        return $response;
    }
148530
public function getJoinColumn(callable $callback = null)
    {
        $joinColumn = reset($this->joinColumns);

        if (is_callable($callback)) {
            $callback($joinColumn);
        }

        return $joinColumn;
    }
1307665
public function prepareCallback($callback)
    {
        $result       = $callback;
        if (is_string($callback) && ($callbackInfo = $this->parseHandlerStr($callback))
            && class_exists($callbackInfo['class']) && method_exists(($controller
                = new $callbackInfo['class']), $callbackInfo['method'])) {
            $result = [$controller, $callbackInfo['method']];
        } elseif (!is_callable($callback)) {
            throw new \pwf\exception\HttpNotFoundException();
        }
        return $result;
    }
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);
            }
        }
    }
1239310
private function getCallback($callback)
    {
        if (is_callable($callback)) {
            if (is_array($callback)) {
                $callback = function (Vertex $vertex) use ($callback) {
                    return call_user_func($callback, $vertex);
                };
            }
            return $callback;
        }

        static $methods = array(
            self::ORDER_ID => 'getId',
            self::ORDER_GROUP => 'getGroup'
        );

        if (!is_int($callback) || !isset($methods[$callback])) {
            throw new InvalidArgumentException('Invalid callback given');
        }

        $method = $methods[$callback];

        return function (Vertex $vertex) use ($method) {
            return $vertex->$method();
        };
    }
1119186
public function first(callable $callback = null)
    {
        if (null === $callback) {
            return reset($this->items);
        }

        return $this->filter($callback)->first();
    }
656088
public function getCallBack($request, \Exception $exception)
    {
        foreach ($this->exceptionsCallbacks as $callback){
            if(is_callable($callback)){
                $data = call_user_func($callback,$request,$exception);
                if(!is_null($data)){
                    return $data;
                }
            }

        }
    }
341296
private function _first(callable $callback = null)
    {
        $values = $this->getValues();
        if ($callback){
            foreach($values as $key => $value){
                if ($callback($value, $key)){
                    return $value;
                }
            }
        }
        else{
            return empty($values) ? null : $values[0];
        }
        return null;
    }
149438
public function select ($callback)
	{
		if(!is_callable($callback)) {
			throw new \InvalidArgumentException('Invalid (not callable) callback given');
		}

		return $this->map(function ($v) use ($callback) {
			if ($callback($v)) {
				return $v;
			}
		});
	}
663804
public function handle(callable $callBack = null)
    {
        $ipAddress = $this->request->getClientIp();

        $this->setIpAddress($ipAddress);

        $isAllowed = parent::handle($callBack);

        if (!$isAllowed && $this->throwError) {
            throw new HttpException($this->errorCode, sprintf('%s [ip: %s]', $this->errorMessage, $ipAddress));
        }

        return $isAllowed;
    }
1188185
public function setCallback($callback)
    {
        if (is_array($callback)) {
            require_once 'Zend/Server/Method/Callback.php';
            $callback = new Zend_Server_Method_Callback($callback);
        } elseif (!$callback instanceof Zend_Server_Method_Callback) {
            require_once 'Zend/Server/Exception.php';
            throw new Zend_Server_Exception('Invalid method callback provided');
        }
        $this->_callback = $callback;
        return $this;
    }
1115302
public static function make(\Closure $callback = null)
    {
        self::$instance = new static();

        if ($callback instanceof \Closure) {
            return $callback(self::$instance);
        }

        return self::$instance;
    }
580643
public function setCallback($callback)
    {
        if (!$callback instanceof Closure) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Invalid parameter for callback: must be %s',
                Closure::class
            ));
        }

        return parent::setCallback($callback);
    }