Defines a shared service

@param string   $name     The service name
@param callable $callback The service factory callback

@return void
437233
public function set(string $name, callable $callback): void
    {
        $this->services[$name] = function ($c) use ($callback) {
            static $object;

            if ($object === null) {
                $object = $callback($c);
            }

            return $object;
        };
    }
126003
public function of($name, Closure $callback = null)
    {
        if (!isset($this->names[$name])) {
            $this->names[$name]       = $this->make($callback);
            $this->names[$name]->name = $name;
        }
        $form = $this->names[$name];
        event('form.' . $name, [&$form]);
        event(new Form($name, $form));
        return $form;
    }
1342455
public static function set($name, $definition, $shared = false, $locked = false)
    {
        if (isset(self::$services[$name]) && self::$services[$name]->isLocked()) {
            throw new ServiceLockedException(sprintf('Service "%s" is locked.', $name));
        }

        self::$services[$name] = new Service($name, $definition, $shared, $locked);
    }
66878
public function table($name, callable $callback)
    {
        $blueprint = new Blueprint($name, $callback);

        $this->blueprints[$name] = $blueprint->build();
    }
489929
public function add(string $name, callable $callback): self
    {
        call_user_func($this->addCallback, $name, $callback);
        return $this;
    }
768905
public function if($name, callable $callback)
    {
        $this->conditions[$name] = $callback;

        $this->directive($name, function ($expression) use ($name) {
            return $expression !== ''
                    ? "<?php if (\Illuminate\Support\Facades\Blade::check('{$name}', {$expression})): ?>"
                    : "<?php if (\Illuminate\Support\Facades\Blade::check('{$name}')): ?>";
        });

        $this->directive('else'.$name, function ($expression) use ($name) {
            return $expression !== ''
                ? "<?php elseif (\Illuminate\Support\Facades\Blade::check('{$name}', {$expression})): ?>"
                : "<?php elseif (\Illuminate\Support\Facades\Blade::check('{$name}')): ?>";
        });

        $this->directive('end'.$name, function () {
            return '<?php endif; ?>';
        });
    }
1121391
public function mixin(string $name, callable $callback): self
    {
        $this->data->mixin($name, $callback);
        return $this;
    }
483334
public function filter($name, $callback)
	{
		$this->events->listen('router.filter: '.$name, $this->parseFilter($callback));
	}
1198736
public function register($name, $callback)
    {
        $this->widgets[$name] = $callback;

        $this->registerBlade($name);
    }
996603
public function param( $param_name, $callback )
	{
		if( is_callable($callback) )
		{
			$this->_params[$param_name] = $callback( new request() );
		}
		else
		{
			$this->_params[$param_name] = $callback;
		}
	}
243042
public function addTab($name, $callback = null)
    {
        $c = parent::addTab($name, $callback);

        return $c->add([$this->formLayout, 'form' => $this->form]);
    }
758776
public static function configureScope(callable $callback): void
    {
        $self = Hub::getCurrent()->getIntegration(self::class);

        if (!$self instanceof self) {
            return;
        }

        configureScope($callback);
    }
285708
public function addTask($name, $callback)
    {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('Task should be a callback.');
        }

        $this->tasks[$name] = $callback;

        return $this;
    }
586448
public function setService($name, $service)
    {
        $this->validate($service);
        parent::setService($name, $service);
    }
264525
public function singleton(string $name, callable $callback = null)
    {
        static $instance = [];

        // if closure callback given we will create a singleton instance of class
        // and return it to user
        if ($callback instanceof Closure) {
            if (!isset($instance[$name])) {
                $instance[$name] = $callback($this);
            }

            return $this->stack[$name] = $instance[$name];
        }

        /*
         | If callback is not instance of closure then we will simply
         | create a singleton instance and return it
         */
        if (!isset($instance[$name])) {
            $instance[$name] = new $name();
        }

        return $instance[$name];
    }
945657
public function addStaticMethod(
        string $name,
        callable $callback = null
    ): self {
        if ($this->isFinalized) {
            throw new FinalizedMockException();
        }
        if (!$callback) {
            $callback = $this->emptyCallback;
        }

        $this->customStaticMethods[$name] = [
            $callback,
            $this->invocableInspector->callbackReflector($callback),
        ];

        return $this;
    }
762522
public function register($name, Closure $callback)
    {
        $this->checkCallbackName($name);

        $this->callbacks[$name] = $callback;

        return $this;
    }