Creates the instance callback which is passed to the wrappers if they exist.

@param string $name
@param mixed $spec
@return \Closure
7434
private function createInstanceCallback($name, $spec)
    {
        if (is_string($spec) && class_exists($spec)) {
            $spec = new $spec;
        }
        if ($spec instanceof ServiceFactoryInterface) {
            return function () use ($spec) {
                return $spec->createService($this);
            };
        }
        if (is_callable($spec)) {
            return function () use ($spec) {
                return $spec($this);
            };
        }
        if (is_object($spec)) {
            return function () use ($spec) {
                return $spec;
            };
        }
        throw new Exception\InvalidServiceException($name, $spec);
    }
1015834
public function make(string $name, array $data = [], \Closure $callback = null)
    {
        $this->setWidgetName($name);
        $this->data = $data;
        /*
         | If second param given as closure then we will
         | return callback
         */
        if (!is_null($callback) && $callback instanceof \Closure) {
            return $callback($this);
        }

        /*
         | return object
         */
        return $this->render();
    }
957118
public static function invalidClass($spec)
    {
        if (is_object($spec)) {
            $spec = get_class($spec);
        }

        return new static(sprintf(
            'Configuration class `%s` must implement `%s`',
            $spec,
            ConfigurationInterface::class
        ));
    }
952415
public function create($name, Closure $resolver)
    {
        $builder = new MenuBuilder($name, $this->config);

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

        $this->menus[$name] = $builder;

        return $resolver($builder);
    }
1012558
public function create($name, $callback)
    {
        $this->_name = $name;
        $this->_class = $callback();

        $GLOBALS['providers'][$this->_name] = $this->_class;
    }
1088839
public function makeSource($spec)
    {
        if (is_string($spec)) {
            $spec = array(
                'filepath' => $spec,
            );
        } elseif ($spec instanceof Minify_SourceInterface) {
            return $spec;
        }

        $source = null;

        if (empty($spec['filepath'])) {
            // not much we can check
            return new Minify_Source($spec);
        }

        if ($this->options['resolveDocRoot'] && 0 === strpos($spec['filepath'], '//')) {
            $spec['filepath'] = $this->env->getDocRoot() . substr($spec['filepath'], 1);
        }

        if (!empty($this->options['fileChecker'])) {
            $spec['filepath'] = call_user_func($this->options['fileChecker'], $spec['filepath']);
        }

        if ($this->options['checkAllowDirs']) {
            $allowDirs = (array)$this->options['allowDirs'];
            $inAllowedDir = false;
            $filePath = $this->env->normalizePath($spec['filepath']);
            foreach ($allowDirs as $allowDir) {
                if (strpos($filePath, $this->env->normalizePath($allowDir)) === 0) {
                    $inAllowedDir = true;
                }
            }

            if (!$inAllowedDir) {
                $allowDirsStr = implode(';', $allowDirs);
                throw new Minify_Source_FactoryException("File '{$spec['filepath']}' is outside \$allowDirs "
                    . "($allowDirsStr). If the path is resolved via an alias/symlink, look into the "
                    . "\$min_symlinks option.");
            }
        }

        $basename = basename($spec['filepath']);

        if ($this->options['noMinPattern'] && preg_match($this->options['noMinPattern'], $basename)) {
            if (preg_match('~\.(css|less)$~i', $basename)) {
                $spec['minifyOptions']['compress'] = false;
                // we still want URI rewriting to work for CSS
            } else {
                $spec['minifier'] = 'Minify::nullMinifier';
            }
        }

        $hoursBehind = $this->options['uploaderHoursBehind'];
        if ($hoursBehind != 0) {
            $spec['uploaderHoursBehind'] = $hoursBehind;
        }

        foreach ($this->handlers as $basenamePattern => $handler) {
            if (preg_match($basenamePattern, $basename)) {
                $source = call_user_func($handler, $spec);
                break;
            }
        }

        if (!$source) {
            throw new Minify_Source_FactoryException("Handler not found for file: $basename");
        }

        return $source;
    }
121373
protected function _setSpec($spec)
    {
        if (!is_null($spec)) {
            $spec = $this->_normalizeIterable($spec);
        }

        $this->spec = $spec;
    }
26004
public function listen($name, $listenerInterface)
    {

        $name = is_object($name) ? get_class($name) : $name;

        if ($listenerInterface instanceof EventListener && $listenerInterface instanceof SubscriberInterface) {
            $listeners = $listenerInterface->getSubscribedEvents();

            foreach ($listeners as $listener => $callback) {
                if (!$callback instanceof Closure) {
                    $callback = [$listenerInterface, $callback];
                }

                if(is_integer($listener)){
                    EventCollector::addListener($name, $callback);

                }else{
                    EventCollector::addListener($name.'.'.$listener, $callback);
                }
            }

        } else {
            EventCollector::addListener($name, $listenerInterface);
        }

        return $this;
    }
123110
protected function callCustomCreator($name, array $config)
    {
        $driver = $config['driver'];

        $callback = $this->customCreators[$driver];

        return call_user_func($callback, $this->app, $name, $config);
    }
323377
public function setSpec(array $spec)
    {
        foreach ($spec as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (method_exists($this, $method)) {
                $this->$method($value);
            }
        }
        return $this;
    }
329917
protected function string(string $name): Closure
    {
        return function (Table $table, MigrationContextInterface $context) use ($name) {
            $length = $context->getModelSchemas()->getAttributeLength($context->getModelClass(), $name);
            $table->addColumn($name, Type::STRING)->setLength($length)->setNotnull(true);
        };
    }
28089
protected function buildClass($name)
    {
        $stub = parent::buildClass($name);

        $this->createJsonConfig($name);

        return $stub;
    }
755734
public function make($name, array $args = [])
    {
        if (! isset($this->classes[$name])) {
            throw new FactoryException('"' . $name . '" is not a registered class');
        }

        $class = new \ReflectionClass($this->classes[$name]);

        return $class->newInstanceArgs($args);
    }
942082
public function resolveCallable(?string $name, callable $closure, ?array $parameters = null)
    {
        $definitions = isset($name) && $this->container->isDefined($name)
            ? $this->container->getDefiniition($name) : null;

        $callable = $this->getCallable($closure);
        $parameters = $parameters ?? $this->resolveParameters($callable->getParameters() ?? null, $definitions);

        return $callable->invokeArgs($parameters);
    }
546302
public function make($name, $parameters = []) {
		$name = $this->getAlias($name);

		if (is_string($name) && $this->resolved($name)) {
			return $this->instances[$name];
		}

		if (is_callable($name) || (is_string($name) && !$this->registered($name))) {
			return $this->build($name, $parameters ?: []);
		}

		list($builder, $singleton) = $this->extractComponentBuilder($name);

		$component = $this->build($builder, $parameters);

		if ($this->hasExtender($name)) {
			$extenders = $this->getExtenders($name);
			$component = $this->resolveExtend($component, $extenders);
		}

		if ($singleton) {
			$this->instance($name, $component);
		}

		return $component;
	}
1182965
private function createServiceFromDelegator(string $name, array $options = null)
    {
        // @todo: This selection is necessary only because lazy services
        // configuration currently requires an explicit Delegator definition
        if ($this->delegators[$name][0] === Proxy\LazyServiceFactory::class) {
            return $this->createServiceFromLazyServiceDelegator($name, $options);
        }

        $creationCallback = $this->delegatorCallbackCache[$name] ?? null;
        if ($creationCallback) {
            $object = $creationCallback($this->creationContext, $name, $creationCallback, $options);
            return $object;
        }

        $creationCallback = function () use ($name, $options) {
            return $this->createServiceFromFactory($name, $options);
        };

        foreach ($this->delegators[$name] as $index => $delegatorFactory) {
            if (is_string($delegatorFactory) && class_exists($delegatorFactory)) {
                $delegatorFactory = new $delegatorFactory();
                if ($delegatorFactory instanceof DelegatorFactoryInterface) {
                    $this->delegators[$name][$index] = $delegatorFactory;
                    $creationCallback = function () use ($delegatorFactory, $name, $creationCallback, $options) {
                        return $delegatorFactory($this->creationContext, $name, $creationCallback, $options);
                    };
                    continue;
                }
            }
            if (is_callable($delegatorFactory)) {
                $creationCallback = function () use ($delegatorFactory, $name, $creationCallback, $options) {
                    return $delegatorFactory($this->creationContext, $name, $creationCallback, $options);
                };
                continue;
            }
            if (is_string($delegatorFactory)) {
                throw InvalidArgumentException::fromInvalidDelegatorFactoryClass($delegatorFactory);
            }
            throw InvalidArgumentException::fromInvalidDelegatorFactoryInstance($delegatorFactory);
        }

        //cache the callback for later requests
        $this->delegatorCallbackCache[$name] = $creationCallback;
        return $creationCallback($this->creationContext, $name, $creationCallback, $options);
    }
1078243
private function createMethod(string $name): MethodInterface
    {
        $class = 'Ekyna\\Component\\Dpd\\EPrint\\Method\\' . ucwords($name);
        if (class_exists($class)) {
            /** @var MethodInterface $instance */
            return new $class($this->getClient());
        }

        throw new RuntimeException("Method {$name} does not exist");
    }