Actual callback method

@param  callable $callable
@param \AMQPEnvelope $envelope
@param \AMQPQueue $queue
@return boolean
@throws \Exception
@throws \RuntimeException
487420
protected function _callback(callable $callable, AMQPEnvelope $envelope, AMQPQueue $queue)
    {
        if ($this->stop) {
            return false;
        }

        if ($envelope === false) {
            return false;
        }

        if ($this->stop) {
            $this->log('-> Putting job back into the queue', 'warning');
            $queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
            return false;
        }

        $result = false;

        try {
            $this->_working = true;

            $body = $envelope->getBody();
            $compressed = $envelope->getContentEncoding() === 'gzip';

            if ($compressed) {
                $body = gzuncompress($body);
            }

            switch ($envelope->getContentType()) {
                case 'application/json':
                    $result = $callable(json_decode($body, true), $envelope, $queue);
                    break;

                case 'application/text':
                    $result = $callable($body, $envelope, $queue);
                    break;

                default:
                    throw new RuntimeException('Unknown serializer: ' . $envelope->getContentType());
            }

        } catch (Exception $e) {
            $queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
            throw $e;
        } finally {
            $this->_working = false;
        }

        if ($result !== false) {
            return $queue->ack($envelope->getDeliveryTag());
        }

        return $queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
    }
352354
public function push($callable, $args = [], $options = [])
    {
        $queue = $this->engine->setting($options, 'queue');
        $item = [
            'queue' => $queue,
            'class' => $callable,
            'args'  => [$args],
            'id'    => md5(uniqid('', true)),
            'queue_time' => microtime(true),
        ];
        $success = $this->engine->push($item, $options);

        unset($item['id']);
        if ($success) {
            $item['id'] = $this->engine->lastJobId();
        }

        $item['args'] = $args;
        $this->dispatchEvent('Queue.afterEnqueue', [
            'item' => $item,
            'success' => $success,
        ]);

        return $success;
    }
219165
protected function callHandler(callable $handler, $payload)
    {
        try {
            return $handler($payload);
        } catch (\Exception $e) {
            if (property_exists($this, 'app') && $this->app instanceof ServiceContainer) {
                $this->app['logger']->error($e->getCode().': '.$e->getMessage(), [
                    'code' => $e->getCode(),
                    'message' => $e->getMessage(),
                    'file' => $e->getFile(),
                    'line' => $e->getLine(),
                ]);
            }
        }
    }
532025
public boolean process(MessageEnvelope envelope) {
		if (this.event == null) {
			return false;
		}

		boolean triggered = this.event.verifyEventCondition(envelope);
		if (triggered) {
			beforeReply(envelope);
			if (this.reply != null) {
				this.reply.reply(envelope);
			}
			afterReply(envelope);
		}
		return triggered;
	}
53992
public function setCallback(Closure $callback = null)
    {
        if ($this->callback !== null || $callback === null) {
            throw new \RuntimeException("Cannot redeclare this comparer callback.");
        }

        $this->callback = Closure::bind($callback, $this, get_called_class());
    }
513303
public function leftJoin($table, callable $callable = null)
    {
        $table = $this->getPrefix().$table;

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

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

            return $this;
        }

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

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

            return $this;
        }

        throw new QueryBuilderException(
            'The inner join clause is already in effect.',
            E_ERROR
        );
    }
269268
public static function run( Callable $callable ) {

		try {

			// catch fatal errors
			register_shutdown_function(['\\yolk\\exceptions\\Handler', 'checkFatal']);

			// use our error handler
			$error_handler = set_error_handler(static::$error_handler);

			$args = func_get_args();
			array_shift($args);

			$result = call_user_func_array($callable, $args);

			// restore the original error handler
			// if $error_handler is null then passing it to set_error_handler() will fail on PHP < v5.5
			// so we create an empty error handler thereby causing PHP to run it's own handler.
			set_error_handler($error_handler ?: function() { return false; });

			return $result;

		}
		catch( \Exception $e ) {
			static::exception($e);
		}

	}
164671
public function insert($table, callable $callable = null)
    {

        $this->connect($table);
        $insert = new Insert($this);

        return $callable($insert);
    }
1036306
public function transaction(callable $callable)
    {
        $this->beginTransaction();

        try {
            call_user_func_array($callable, [$this]);

            $this->commit();

            return $this;
        } catch (\Exception $e) {
            $this->rollBack();

            throw $e;
        }
    }
1251996
public function runWithBeforeAfterEvents(callable $callable)
    {
        $results = false;

        // Fire the task if the before event passes
        if ($this->fireEvent('before')) {
            $results = $this->timer->time($this, $callable);
            if ($results && !$this->wasHalted()) {
                $this->fireEvent('after');
            }
        }

        return $results;
    }
808195
public function call($key, $callable)
    {
        if (!is_callable($callable)) {
            throw new \InvalidArgumentException('Not a valid callable.');
        }

        if ($this->exists($key)) {
            return $this->get($key);
        }

        $args = func_get_args();
        array_shift($args);
        array_shift($args);

        $value = call_user_func_array($callable, $args);

        $this->set($key, $value);

        return $value;
    }
1325815
public function useTransaction(callable $callable)
    {
        $connection = Propel::getConnection();
        $connection->beginTransaction();

        try {
            $callable();
            $connection->commit();
        } catch (\Exception $exception) {
            $connection->rollBack();
            throw $exception;
        } catch (\Throwable $throwable) {
            $connection->rollBack();
            throw $throwable;
        }
    }
331861
public function call(callable $callable, ...$params)
    {
        foreach ($this->settings as $key => $value) {
            $this->ini->set($key, $value);
        }

        $result = null;
        $exception = null;
        try {
            $result = $callable(...$params);
        } catch (\Throwable $e) {
            $exception = $e;
        }

        $this->ini->cleanup();

        if ($exception) {
            throw $exception;
        }

        return $result;
    }
873573
public function consumeMessages($queue, $callback, $flags = AMQP_NOPARAM)
    {
        if (!isset($this->_queues[$queue])) {
            throw new InvalidKeyException(['consume message from queue failed: `:queue queue is NOT exists`', 'queue' => $queue]);
        }

        try {
            $this->_queues[$queue]->consume(function (\AMQPEnvelope $envelope) use ($callback, $queue) {
                return $callback(new Message($this, $queue, $envelope));
            }, $flags);
        } catch (\Exception $e) {
            throw new AmqpException('consume `:queue` queue message failed: ', $e->getMessage());
        }
    }
610886
public function addProcessor($callback, $processBufferRecord = false)
    {
        if (!is_callable($callback) && !$this->isInstanceOf($callback, ProcessorInterface::class)) {
            throw new \InvalidArgumentException('Processor must be valid callable or an instance of ' . ProcessorInterface::class);
        }

        if ($processBufferRecord) {
            $this->bufferProcessors->prepend($callback);
        } else {
            $this->processors->prepend($callback);
        }


        return $this;
    }
734552
protected function callableWithRoute(callable $callable)/*# : bool */
    {
        /* @var EventCapableAbstract $route */
        $route = $this->result->getRoute();
        $param = ['result' => $this->result];
        if ($route->trigger(Route::EVENT_BEFORE_HANDLER, $param)) {
            call_user_func($callable, $this->result);
            $route->trigger(Route::EVENT_AFTER_HANDLER, $param);
            return true;
        }
        $this->result->setHandler(null);
        return false;
    }
143886
public function protect($callable)
    {
        try {
            return parent::protect($callable);
        } catch (PimpleExpectedInvokableException $e) {
            throw new ExpectedInvokableException(
                $e->getMessage(),
                $e->getCode(),
                $e
            );
        } catch (\Throwable $e) {
            throw new ContainerException(
                $e->getMessage(),
                $e->getCode(),
                $e
            );
        }
    }