Get the initial slice to begin the stack call.

@param  \Closure  $destination

@return \Closure
176242
protected function prepareDestination(BaseClosure $destination)
    {
        return function ($passable) use ($destination) {
            try {
                return \call_user_func($destination, $passable);
            } catch (Exception $e) {
                return $this->handleException($passable, $e);
            } catch (Throwable $e) {
                return $this->handleException($passable, new FatalThrowableError($e));
            }
        };
    }
390892
public function transaction(Closure $closure) {
        try {
            $this->beginTransaction();
            //执行事务
            $closure();
            $this->commit();
        } catch (Exception $e) {
            //回滚事务
            $this->rollBack();
        }

        return $this;
    }
754642
private function tabSorter(): Closure
    {
        return static function (ModuleTabInterface $x, ModuleTabInterface $y): int {
            return $x->getTabOrder() <=> $y->getTabOrder();
        };
    }
336568
public function createConsumer(Destination $destination): Consumer
    {
        InvalidDestinationException::assertDestinationInstanceOf($destination, FsDestination::class);

        $consumer = new FsConsumer($this, $destination, $this->preFetchCount);

        if ($this->pollingInterval) {
            $consumer->setPollingInterval($this->pollingInterval);
        }

        return $consumer;
    }
595152
protected function getSlice()
    {
        return function ($stack, $pipe) {
            return function () use ($stack, $pipe) {
                if ($pipe instanceof Closure) {
                    // If the pipe is an instance of a Closure, we will just call it directly but
                    // otherwise we'll resolve the pipes out of the container and call it with
                    // the appropriate method and arguments, returning the results back out.
                    return call_user_func($pipe, $stack);
                } else {
                    $parameters = [$stack];
                }

                return call_user_func_array([$pipe, $this->method], $parameters);
            };
        };
    }
824999
static function transaction(Closure $closure, $name = NULL, $mode = NULL)
	{
		try {
			$transactionStarted = static::begin($name, $mode);
			$result = call_user_func($closure);
			if ($transactionStarted) static::commit($name);

			return $result;
		} catch (Exception $e) {
			if (isset($transactionStarted) && $transactionStarted) static::rollback($name);
			throw $e;
		}
	}
905023
private function withReadPreference($object, \Closure $closure)
    {
        if ( ! isset($this->query['readPreference'])) {
            return $closure();
        }

        $prevReadPref = $object->getReadPreference();
        $object->setReadPreference($this->query['readPreference'], $this->query['readPreferenceTags']);

        try {
            return $closure();
        } finally {
            $prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : [];
            $object->setReadPreference($prevReadPref['type'], $prevTags);
        }
    }
1287482
public function checkout($destination)
    {
        $repository = $this->credentials->getCurrentRepository();

        $arguments = [
            $this->quote($repository->repository),
            '-b '.$repository->branch,
            $this->quote($destination),
        ];

        return $this->clone($arguments, $this->getCredentials());
    }
767782
public function setInitClosure(CLOSURE $initClosure = null) {
        if ($initClosure === null)
            throw new \Exception ("the initClosure must be set for Stepcontroller");
        $initClosure = $this->generateClosure($initClosure);
        $closureParameter = $this->standardClosureArguments();
        $initClosure($closureParameter);
    }
49146
private function getSourceCode(\Closure $closure) {

		$reflection = new \ReflectionFunction($closure);

		$file = $reflection->getFileName();
		$source = file($file, FILE_IGNORE_NEW_LINES);

		$startLine = $reflection->getStartLine();
		$endLine = $reflection->getEndLine() - 1;

		return implode(
			PHP_EOL,
			array_slice($source, $startLine, $endLine - $startLine)
		);

	}
402856
public function checkout($destination)
    {
        $repository = $this->credentials->getCurrentRepository();
        $arguments = array_map([$this, 'quote'], [
            $repository->repository,
            $destination,
        ]);

        // Build flags
        $flags = ['--branch' => $repository->branch];
        if ($this->config->getContextually('vcs.shallow')) {
            $flags['--depth'] = 1;
        }

        return $this->clone($arguments, $flags);
    }
267603
private function withReadPreference($object, \Closure $closure)
    {
        if ( ! isset($this->query['readPreference'])) {
            return $closure();
        }

        $prevReadPref = $object->getReadPreference();
        $object->setReadPreference($this->query['readPreference'], $this->query['readPreferenceTags']);

        try {
            $result = $closure();
        } catch (\Exception $e) {
        }

        $prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : null;
        $object->setReadPreference($prevReadPref['type'], $prevTags);

        if (isset($e)) {
            throw $e;
        }

        return $result;
    }
643602
public function foldlWithKey(callable $closure, $initial)
    {
        $accumulator = $initial;

        foreach ($this->value as $key => $value) {
            $accumulator = Std::call($closure, $accumulator, $value, $key);
        }

        return $accumulator;
    }
1354602
public static function getOrSet($key, \Closure $closure)
    {
        $key = Cache::key($key);
        if (!isset(self::$cache[$key])) {
            self::$cache[$key] = $closure();
        }
        return self::$cache[$key];
    }
415062
public function filter(Closure $closure): self
    {
        $filter = new Iterator\CustomFilterIterator($this->getIterator(), [$closure]);

        return new self(iterator_to_array($filter));
    }
457689
protected function getRoute($destination)
    {
        $destinationPieces = explode('/', $destination);

        $mappingNode = $this->routeMapping;
        $argValues = array();
        foreach($destinationPieces as $destinationPiece) {
            if (isset($mappingNode[$destinationPiece])) {
                $mappingNode = $mappingNode[$destinationPiece];
            } elseif (isset($mappingNode['_wildcard'])) {
                $argValues[] = $destinationPiece;
                $mappingNode = $mappingNode['_wildcard'];
            } else {
                throw new Exception("Route mapping not found for destination '{$destination}'");
            }
        }

        if (!isset($mappingNode['_mapping']) || !($mappingNode['_mapping'] instanceof Route\Mapping)) {
            throw new Exception("Route mapping not found for destination '{$destination}'");
        }

        /**
         * @var Route\Mapping $mapping;
         */
        $mapping = $mappingNode['_mapping'];

        $patternPieces = explode('/', $mapping->destinationPattern());
        $routeArgs = array();
        foreach ($patternPieces as $piece) {
            if($this->isWildcard($piece)) {
                $argName = substr($piece, 1, -1);
                $routeArgs[$argName] = array_shift($argValues);
            }
        }

        $this->validateRouteMapping($mapping);

        return new Route($mapping->controller(), $mapping->action(), $routeArgs);
    }
1314679
final public function firstArray( $closure=NULL ) {
      $type_fetch = $this->type_fetch;
      $this->type_fetch = 'assoc';
      $data = $this->first( $closure );
      $this->type_fetch = $type_fetch;
      return $this->data = $data;
   }