Fetch information about the closure.

@param \Closure $closure
@return array
761093
private function describeClosure(\Closure $closure): array
    {
        try {
            $r = new \ReflectionFunction($closure);
        } catch (\ReflectionException $e) {
            return ['closure' => 'unable to resolve'];
        }

        return [
            'name' => $r->getName() . " (lines {$r->getStartLine()}:{$r->getEndLine()})",
            'file' => $r->getFileName(),
            'this' => $r->getClosureThis()
        ];
    }
1084637
public function each(\Closure $closure): self
    {
        // init
        $array = [];

        foreach ($this->getGenerator() as $key => $value) {
            $array[$key] = $closure($value, $key);
        }

        return static::create(
            $array,
            $this->iteratorClass,
            false
        );
    }
687429
public function apply($closure)
    {
        foreach ($this as $key => $val) {
            $this->offsetSet($key, $closure($val, $key, $this));
        }
        return $this;
    }
170364
public static function group($group, \Closure $closure)
    {
        self::$group = $group;
        call_user_func($closure, self::getInstance());
        self::$group = null;
    }
307206
public function each(Closure $closure)
    {
        foreach ($this->stack as &$item) {
            $closure($item);
        }

        return $this;
    }
262339
private static function analyze(\Closure $closure)
    {
        $reflection = new ReflectionClosure($closure);
        $scope = $reflection->getClosureScopeClass();

        $data = [
            'reflection' => $reflection,
            'code' => $reflection->getCode(),
            'hasThis' => $reflection->isBindingRequired(),
            'context' => $reflection->getUseVariables(),
            'hasRefs' => false,
            'binding' => $reflection->getClosureThis(),
            'scope' => $scope ? $scope->getName() : null,
            'isStatic' => $reflection->isStatic(),
        ];

        return $data;
    }
1161403
final public function queryArray( string $sql, $closure=NULL ) {
      $type_fetch = $this->type_fetch;
      $this->type_fetch = 'assoc';
      $this->query( $sql );
      $this->type_fetch = $type_fetch;
      // $this->data = array_map(function($v){return(array)$v;},$this->data);
      if ($closure instanceof \Closure) {
         $this->data = $closure( $this->data, $this );
      }
      return $this->data ?: [];
   }
400456
public function map(\Closure $callback)
    {
        $result = [];
        foreach ($this->value as $entity) {
            $result[] = $callback($entity);
        }

        return $result;
    }
178139
protected function getExtender($abstract, Closure $closure)
		{
			// To "extend" a binding, we will grab the old "resolver" Closure and pass it
			// into a new one. The old resolver will be called first and the result is
			// handed off to the "new" resolver, along with this Eventable instance.
			$resolver = $this->bindings[$abstract]['concrete'];

			return function($Eventable) use ($resolver, $closure) {
				return $closure($resolver($Eventable), $Eventable);
			};
		}
907835
public function fmap(callable $closure)
    {
        return $this->bind(function ($a) use ($closure) {
            return $this->of($closure($a));
        });
    }
491612
public function resolveClosure(Closure $closure, array $args = [])
    {
        $closureRef = new ReflectionFunction($closure);
        $dependencies = $this->getMethodDependencies($closureRef, $args);

        return $closureRef->invokeArgs($dependencies);
    }
1137782
public static function find(\Closure $filterFn = null, bool $applySetters = false) : array
    {
        $connection = self::getConnection();
        $table = self::getModelProperty('table');
        $query = $connection->createQuery()
            ->from($table);

        //Filter results
        if (!is_null($filterFn)) {
            $filterFn($query);
        }

        $objList = [];
        $searchKeys = static::getPrimaryKeys();
        foreach ($searchKeys as &$key) {
            $key = $table.'.'.$key;
        }

        $result = $query->execute();

        if ($result->count()) {
            while ($row = $result->fetch()) {
                $instance = new static();

                $rowData = $row->getData();

                foreach (self::getDateFields() as $dateField) {
                    $rowData[$dateField] = date_create_from_format(
                        $connection->getDateFormat(),
                        $rowData[$dateField]
                    );
                }

                $instance->fill($rowData, $applySetters);

                $objList[] = $instance;
            }
        }

        return $objList;
    }
852403
public function orWhere(\Closure $closure = null) {
        $this->query->push(['OR']);
        if($closure !== null) $closure($this);

        return $this;
    }
201992
public function describe($description, \Closure $closure)
    {
        $context = clone $this;
        $group = new ExampleGroup($description, $context, $this->__stack->top());
        $this->__stack->top()->add($group);
        $this->__stack->push($group);
        $context->run($closure);
        $this->__stack->pop();
        return $group;
    }
89345
public function getRelationCountQuery($closure)
    {
        return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [
            [
                'pivot.' . $this->localKey, 'exp', Db::raw('=' . $this->parent->getTable() . '.' . $this->parent->getPk()),
            ],
        ])->fetchSql()->count();
    }
9105
public static function mapValues(array $array, Closure $closure = null): array
    {
        if (is_null($closure)) {
            $closure = '__::identity';
        }
        $resultArray = [];
        foreach ($array as $key => $value) {
            $resultArray[$key] = call_user_func_array($closure, [$value, $key, $array]);
        }

        return $resultArray;
    }
896008
public function after(\Closure $closure)
    {
        $key = 'after';
        $after = new Hook($key, $closure, $this->current);
        $this->current->setHook($key, $after);
    }