{@inheritdoc}
@param callable  $closure  Callback specification: `function ($a, $b): int`
@return \CharlotteDunois\Collect\Collection
512458
function sortCustom(callable $closure) {
        $args = $this->baseStorageArgs;
        $args[] = parent::sortCustom($closure)->all();
        
        return (new static(...$args));
    }
104438
public function filter($closure) {
        $collection = new Collection();

        foreach ($this->_datas as $data) {
            if ($closure($data)) {
                $collection->add($data);
            }
        }

        return $collection;
    }
1241827
public function getRelationCountQuery($closure)
    {
        if ($closure) {
            $closure($this->query);
        }

        return $this->query
            ->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $this->parent->getPk())
            ->fetchSql()
            ->count();
    }
1280157
public function collection(string $identifier, ?Closure $callback = null) : Collection {
        if ( ! isset($this->collections[$identifier])) {
            $directory = $this->prepareDefaultDirectory();

            $this->collections[$identifier] = new Collection($directory, $identifier);
        }

        // If the collection has been given a callable closure then we'll execute the closure with
        // the collection instance being the only parameter given. This allows users to begin
        // using the collection instance to add assets.
        if (is_callable($callback)) {
            call_user_func($callback, $this->collections[$identifier]);
        }

        return $this->collections[$identifier];
    }
607990
public function callWithDisabledAuth(Closure $closure)
    {
        if ($this->isDisabledAuth()) {
            return call_user_func($closure);
        }

        try {
            $this->disableAuth();

            return call_user_func($closure);
        } finally {
            $this->enableAuth();
        }
    }
1318825
public function filter(\Closure $callback)
    {
        $collection = new static();

        foreach ($this as $element) {
            if ($callback($element)) {
                $collection->attach($element);
            }
        }

        return $collection;
    }
796750
public function filter(\Closure $closure, $keepKeys = false)
    {
        $collection = new Collection();

        $i = 0;
        foreach ($this->items as $key => $value) {
            if ( ! $closure($value, $key, $i++)) {
                $keepKeys || $key = null;
                $collection->add($value, $key);
            }
        }

        return $collection;
    }
1171018
public function indexes(Closure $callback)
    {
        $indexes = new Query\Indexes($this->collection);
        $callback($indexes);

        return $this;
    }
907375
public function make(string $name, ?Closure $callback = null) : Collection {
        return $this->collection($name, $callback);
    }
627976
protected function buildSerializableClosure(\Closure $closure)
    {
        switch (true) {
            case class_exists('SuperClosure\\SerializableClosure'):
                return new \SuperClosure\SerializableClosure($closure);

            default:
                return new \Jeremeamia\SuperClosure\SerializableClosure($closure);
        }
    }
220163
public function sort(Closure $closure)
    {
        $sorted = clone $this;

        $sorted->models = Objects::sort($sorted->models, $closure);

        return $sorted;
    }
1185091
private function runViaLaravelCollection($closure, $method = null)
    {
        $collection = new TightencoCollect($this->items);

        $result = $closure($collection);

        if (!$this->methodMustReturnArray($method)) {
            $result = $this->coollectizeItems($result);
        }

        $this->items = $collection->all();

        return $result;
    }
741782
public function resolveClosure(\Closure $closure)
    {
        $reflection = new \ReflectionFunction($closure);

        $dependencies = $reflection->getParameters();
        $instances = $this->resolveDependencies($dependencies); // Actually resolve the dependencies
        $o = $reflection->invokeArgs($instances);

        return $o;
    }
400911
public static function runInTrans(\Closure $closure) {
        /* @var $connection Connection */
        $connection = Pool::get(Connection::class);
        $pool = ResourcePool::instance();
        //加锁保证事物内使用的是同一连接
        $pool->lock($connection);
        try {
            $value = $connection->runInTrans($closure);
            //释放锁
            $pool->unLock($connection);
            //释放连接
            $pool->release($connection);
            return $value;
        } catch (\RuntimeException $e) {
            $pool->unLock($connection);
            $pool->release($connection);
            throw $e;
        } catch (\Error $e) {
            $pool->unLock($connection);
            $pool->release($connection);
            throw $e;
        }
    }
981898
public function filter(callable $callback): CollectionInterface
    {
        $collection = clone $this;
        $collection->data = \array_merge([], \array_filter($collection->data, $callback));

        return $collection;
    }
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));
    }
647163
public function getFilterCallback(Closure $closure)
  {
    $filter = function(&$item) use ($closure){
      $closure($item);
      return true;
    };
    return $filter;
  }