Let

@param string $name
@param \Closure $closure
762033
public function let($name, \Closure $closure)
    {
        $this->__stack->top()->getContext()->setFactory($name, $closure);
    }
357089
public function eachFillable(Closure $closure)
    {
        /** @var FillableField $item */
        foreach ($this->items as $item) {
            if ($item->fillable) {
                $closure($item);
            }
        }
    }
414653
public function tweakApplication(Closure $closure): void
    {
        $closure($this->app);

        static::$server->stash([
            'class' => static::class,
            'tweakApplication' => serialize(SerializableClosure::from($closure)),
        ]);
    }
591150
public function addSlot($name, Closure $closure, array $arguments)
    {
        $this->getCurrentContext()->addSlot($name, $closure, $arguments);
    }
541532
public function register($name, Closure $callback): void
    {
        if ($this->has($name)) {
            $this->callbacks = $this->callbacks->put($name, $this->callbacks->get($name, collect())->push($callback));
        } else {
            $builder = new MenuGenerator();

            $builder->setViewFactory($this->viewFactory);

            $this->menus->put($name, $builder);

            $this->callbacks = $this->callbacks->put($name, $this->callbacks->get($name, collect())->push($callback));
        }
    }
1218005
public <T> T get(String name, Closure<String,T> closure){
        T obj = null;
        lock(name);
        try {
            obj = (T)cache.get(name);
            if(obj!=null){
                if(ttl>0 && (created.get(name)+tu.toMillis(ttl)<System.currentTimeMillis())){
                    //invalidate
                    obj = null;
                }
            }
            if(obj!=null){
                gets.put(name, gets.get(name) + 1);
                return obj;
            }
        } finally {
            unlock(name);
        }

        //add obj
        obj = closure.call(name);

        lock(name);
        try {

            created.put(name,System.currentTimeMillis());
            gets.put(name, 1L);
            cache.put(name, obj);

        } finally {
            unlock(name);
        }
        checkSize();
        return obj;
    }
1040539
function filter(callable $closure) {
        $new = array();
        foreach($this->data as $key => $val) {
            $feed = (bool) $closure($val, $key);
            if($feed) {
                $new[$key] = $val;
            }
        }
        
        return (new self($new));
    }
134154
public function make($name, Closure $callback)
    {
        $this->add($name, Menu::make($name, $callback));
    }
862516
public static function extend(BladeCompiler $blade, $name, $closure)
    {
        // For 5.0 after
        if (is_callable([$blade, 'directive'])) {
            $blade->directive($name, $closure);

            return;
        }

        // For 4.x before
        $blade->extend(
            function ($view, BladeCompiler $compiler) use ($name, $closure) {
                $pattern = $compiler->createMatcher($name);

                return preg_replace_callback(
                    $pattern,
                    function ($matches) use ($closure) {
                        if (empty($matches[2])) {
                            return $matches[0];
                        }

                        return $matches[1] . $closure($matches[2]);
                    },
                    $view
                );
            }
        );

        return;
    }
1121047
public function resolveCallableString(string $name, callable $closure, $factory = false)
    {
        if($factory === true) {
            return $this->resolveCallable($name, $closure);
        }

        return $this->resolveCallableFromCache($name, $closure);
    }
131211
protected function registerEvent($name, Closure $callback)
    {
        if (! isset(static::$dispatcher)) {
            $this->initEventDispatcher();
        }

        static::$dispatcher->listen($name, $callback);
    }
890901
public function addMethod($name, Closure $closure)
    {
        if (method_exists($this, $name)) {
            throw new Exception('Overriding core methods not allowed.');
        }

        $this->methods[$name] = $closure;
    }
1043539
function filter(callable $closure) {
        $args = $this->baseStorageArgs;
        $args[] = parent::filter($closure)->all();
        
        return (new static(...$args));
    }
1346050
public function addSlot($name, Closure $closure, array $arguments)
    {
        $this->closures[$name] = $closure;
        $this->arguments[$name] = $arguments;
    }
1098708
public static function bind($nameOrClazz, $toClazz, \Closure $closure = null) {
        unset(static::$instances[ $nameOrClazz ]);
        static::$beansConfig[ $nameOrClazz ] = new BeanDefine($toClazz, $closure);
    }
959863
public function share(Closure $closure)
    {
        return function($container) use ($closure)
        {
            // We'll simply declare a static variable within the Closures and if it has
            // not been set we will execute the given Closures to resolve this value
            // and return it back to these consumers of the method as an instance.
            static $object;

            if (is_null($object)) {
                $object = $closure($container);
            }

            return $object;
        };
    }
194171
public function department($name, Closure $callback)
    {
        $department = $this->createDepartment($name);

        call_user_func($callback, $department);

        if (is_null(static::$departments)) {
            static::$departments = Collection::make([]);
        }

        static::$departments->push($department);

        return $this;
    }