@param callable $fn

@return $this
541921
public function filter(callable $fn)
    {
        $this->items = array_values(array_filter($this->items, $fn));

        return $this;
    }
141205
public function each(callable $callback)
    {
        foreach ($this->nodes as $index => $node) {
            $return_value = \call_user_func($callback, $node, $index);

            if ($return_value === false) {
                break;
            }
        }

        return $this;
    }
952284
public function walkNodes(callable $fn)
    {
        foreach ($this->_children as $node) {
            $node->walkNodes($fn);
        }
        $fn($this);
    }
1357491
public function over($middle, callable $callable = null)
    {
        $this->middle = $middle;

        if ($callable) {
            $callable($this, $this->getMiddleEntity());
        }

        return $this;
    }
699407
public static function mapRequest(callable $fn)
    {
        return function (callable $handler) use ($fn) {
            return function ($request, array $options) use ($handler, $fn) {
                return $handler($fn($request), $options);
            };
        };
    }
1161722
public function pipe(callable $fn, $class = null)
    {
        $this->prepare();

        if (is_string($fn) && !is_null($class)) {
            $instance = new $class;

            $this->_map = call_user_func_array([$instance, $fn], [$this]);
            return $this;
        }

        $this->_map = $fn($this);
        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;
    }
217257
public function preprocess(callable $callback)
    {
        if ($callback instanceof Closure) {
            $callback = $callback->bindTo($this, get_class($this));
        }

        $this->getPreprocessor()->register($callback);
        return $this;
    }
848745
private function boolCall(callable $fn, $flags = null)
    {
        try {
            return $fn();
        } catch (\Exception $e) {
            return $this->triggerError($e->getMessage(), $flags);
        }
    }
85551
public function on(callable $fn, string $option = null): self
    {
        $names = \array_keys($this->allOptions());

        $this->_events[$option ?? \end($names)] = $fn;

        return $this;
    }
1175910
public function _and(callable $callable = null)
    {
        $history = $this->whereNeedAddAndOrOr;
        $this->whereNeedAddAndOrOr = 1;

        if (is_callable($callable)) {
            $history === 0 && $this->whereNeedAddAndOrOr = 0;
            $this->lBrackets();
            call_user_func($callable, $this);
            $this->rBrackets();
        }

        return $this;
    }
1244478
public function on($event, $callable)
    {
        if (!is_callable($callable) && !$callable instanceof \Closure)
            throw new \InvalidArgumentException();

        if (!isset($this->_hooks[$event]))
            $this->_hooks[$event] = array();

        $this->_hooks[$event][] = $callable;

        return $this;
    }
719709
public function extend($name, callable $callable)
    {
        if ($this->parent) {
            $this->parent->extend($name, $callable);
        }

        if ($callable instanceof Closure) {
            $callable = $callable->bindTo($this);
        }

        $this->callables[$name] = $callable;

        return $this;
    }
839
public function invokeWithin($fn, $args = array())
    {
        $this->invocation_context->activate();

        $this->invocation_context->push($this);
        try {
            $result = call_user_func_array($fn, $args);
            $this->invocation_context->pop();
            $this->invocation_context->deactivate();
            return $result;
        } catch (\Exception $e) {
            $this->invocation_context->pop();
            $this->invocation_context->deactivate();
            throw $e;
        }
    }
650403
public function setConvertValueFunction(callable $function)
    {
        $validator = $this->getCallableValidatorConvertValue();
        $validator->setCallableFunction($function);

        if ($validator->isValid() === false) {
            throw $validator->getException();
        }

        $this->convertValueFunction = $function;

        return $this;
    }
1055707
public function on($event, callable $fn) {
        if (!isset($this->events[$event])) {
            $this->events[$event] = [];
        }
        $this->events[$event][] = $fn;
        return $this;
    }
409412
public function each(callable $callback)
    {
        foreach ($this->items as $key => $item) {
            if ($callback($item, $key) === false) {
                break;
            }
        }

        return $this;
    }