Creates a CompletionItem for a Definition

@param Definition $def
@return CompletionItem|null
763246
public static function fromDefinition(Definition $def)
    {
        $item = new CompletionItem;
        $item->label = $def->symbolInformation->name;
        $item->kind = CompletionItemKind::fromSymbolKind($def->symbolInformation->kind);
        if ($def->type) {
            $item->detail = (string)$def->type;
        } else if ($def->symbolInformation->containerName) {
            $item->detail = $def->symbolInformation->containerName;
        }
        if ($def->documentation) {
            $item->documentation = $def->documentation;
        }
        if ($def->isStatic && $def->symbolInformation->kind === SymbolKind::PROPERTY) {
            $item->insertText = '$' . $def->symbolInformation->name;
        }
        return $item;
    }
1067948
private function resolve($definition)
    {
        return !is_null($this->resolver) ? $this->resolver->resolve($definition) : $definition;
    }
993435
public function handle(TypeDefinitionNode $definition): Type
    {
        $nodeValue = new NodeValue($definition);

        return $this->pipeline
            ->send($nodeValue)
            ->through(
                $this->directiveFactory->createNodeMiddleware($definition)
            )
            ->via('handleNode')
            ->then(function (NodeValue $value) use ($definition): Type {
                $nodeResolver = $this->directiveFactory->createNodeResolver($definition);

                if ($nodeResolver) {
                    return $nodeResolver->resolveNode($value);
                }

                return $this->resolveType($definition);
            });
    }
854805
public function parseRulesDefinition($definition): RulesCollection
    {
        if (is_callable($definition)) {

            $definition = [$definition];

        }

        if (is_string($definition)) {

            $definition = array_map('trim', explode('|', $definition));

        }

        if (is_array($definition)) {

            $keys = array_keys($definition);

            return array_reduce($keys, function ($rules, $key) use ($definition) {

                $definition = $definition[$key];

                $rule = $this->parseRuleDefinition($key, $definition);

                return $rules->withRule($rule);

            }, new RulesCollection);

        }

        throw new InvalidRuleFormatException($definition);
    }
471293
public function get_definition($force = false) {
        if ($this->definition === false || $force) {
            $this->load_definition();
        }
        return $this->definition;
    }
971877
private function addService($id, Definition $definition)
    {
        $this->definitionVariables = new \SplObjectStorage();
        $this->referenceVariables = array();
        $this->variableCount = 0;

        $return = array();

        if ($definition->isSynthetic()) {
            $return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
        } elseif ($class = $definition->getClass()) {
            $class = $this->container->resolveEnvPlaceholders($class);
            $return[] = sprintf('@return %s A %s instance', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\'));
        } elseif ($definition->getFactory()) {
            $factory = $definition->getFactory();
            if (is_string($factory)) {
                $return[] = sprintf('@return object An instance returned by %s()', $factory);
            } elseif (is_array($factory) && (is_string($factory[0]) || $factory[0] instanceof Definition || $factory[0] instanceof Reference)) {
                if (is_string($factory[0]) || $factory[0] instanceof Reference) {
                    $return[] = sprintf('@return object An instance returned by %s::%s()', (string) $factory[0], $factory[1]);
                } elseif ($factory[0] instanceof Definition) {
                    $return[] = sprintf('@return object An instance returned by %s::%s()', $factory[0]->getClass(), $factory[1]);
                }
            }
        }

        if ($definition->isDeprecated()) {
            if ($return && 0 === strpos($return[count($return) - 1], '@return')) {
                $return[] = '';
            }

            $return[] = sprintf('@deprecated %s', $definition->getDeprecationMessage($id));
        }

        $return = str_replace("\n     * \n", "\n     *\n", implode("\n     * ", $return));
        $return = $this->container->resolveEnvPlaceholders($return);

        $doc = '';
        if ($definition->isShared()) {
            $doc .= <<<'EOF'

     *
     * This service is shared.
     * This method always returns the same instance of the service.
EOF;
        }

        if (!$definition->isPublic()) {
            $doc .= <<<'EOF'

     *
     * This service is private.
     * If you want to be able to request this service from the container directly,
     * make it public, otherwise you might end up with broken code.
EOF;
        }

        if ($definition->isAutowired()) {
            $doc = <<<EOF

     *
     * This service is autowired.
EOF;
        }

        if ($definition->isLazy()) {
            $lazyInitialization = '$lazyLoad = true';
            $lazyInitializationDoc = "\n     * @param bool    \$lazyLoad whether to try lazy-loading the service with a proxy\n     *";
        } else {
            $lazyInitialization = '';
            $lazyInitializationDoc = '';
        }

        // with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer
        $isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
        $visibility = $isProxyCandidate ? 'public' : 'protected';
        $methodName = $this->generateMethodName($id);
        $code = <<<EOF

    /*{$this->docStar}
     * Gets the '$id' service.$doc
     *$lazyInitializationDoc
     * $return
     */
    {$visibility} function {$methodName}($lazyInitialization)
    {

EOF;

        $code .= $isProxyCandidate ? $this->getProxyDumper()->getProxyFactoryCode($definition, $id, $methodName) : '';

        if ($definition->isSynthetic()) {
            $code .= sprintf("        throw new RuntimeException('You have requested a synthetic service (\"%s\"). The DIC does not know how to construct this service.');\n    }\n", $id);
        } else {
            if ($definition->isDeprecated()) {
                $code .= sprintf("        @trigger_error(%s, E_USER_DEPRECATED);\n\n", $this->export($definition->getDeprecationMessage($id)));
            }

            $code .=
                $this->addServiceInclude($id, $definition).
                $this->addServiceLocalTempVariables($id, $definition).
                $this->addServiceInlinedDefinitions($id, $definition).
                $this->addServiceInstance($id, $definition).
                $this->addServiceInlinedDefinitionsSetup($id, $definition).
                $this->addServiceProperties($id, $definition).
                $this->addServiceMethodCalls($id, $definition).
                $this->addServiceConfigurator($id, $definition).
                $this->addServiceReturn($id, $definition)
            ;
        }

        $this->definitionVariables = null;
        $this->referenceVariables = null;

        return $code;
    }
153411
protected function createTaxTypeFromDefinition(array $definition)
    {
        // Load the referenced zone.
        $definition['zone'] = $this->zoneRepository->get($definition['zone']);
        // Provide defaults.
        if (!isset($definition['compound'])) {
            $definition['compound'] = false;
        }
        if (!isset($definition['display_inclusive'])) {
            $definition['display_inclusive'] = false;
        }
        if (!isset($definition['rounding_mode'])) {
            $definition['rounding_mode'] = PHP_ROUND_HALF_UP;
        }

        $type = new TaxType();
        // Bind the closure to the TaxType object, giving it access to
        // its protected properties. Faster than both setters and reflection.
        $setValues = \Closure::bind(function ($definition) {
            $this->id = $definition['id'];
            $this->name = $definition['name'];
            $this->compound = $definition['compound'];
            $this->displayInclusive = $definition['display_inclusive'];
            $this->roundingMode = $definition['rounding_mode'];
            $this->zone = $definition['zone'];
            if (isset($definition['generic_label'])) {
                $this->genericLabel = $definition['generic_label'];
            }
            if (isset($definition['tag'])) {
                $this->tag = $definition['tag'];
            }
        }, $type, '\CommerceGuys\Tax\Model\TaxType');
        $setValues($definition);

        foreach ($definition['rates'] as $rateDefinition) {
            $rate = $this->createTaxRateFromDefinition($rateDefinition);
            $type->addRate($rate);
        }

        return $type;
    }
192646
private function getDictionaryBuilder(DictionaryDefinition $definition): DictionaryBuilderInterface
    {
        if (!$this->dictionaryBuilders->has($typeName = $definition->getType())) {
            $typeName = 'default';
        }

        return $this->dictionaryBuilders->get($typeName);
    }
644049
private function hydrateDefinitionFactory(Definition $definition, array &$definitionArray)
    {
        if (null !== $definition->getFactory()) {
            foreach ($definition->getFactory() as $argument) {
                $definitionArray['factory'][] = $this->convertArgument($argument);
            }
        }
    }
1265095
private function populateObjectItems($object, array $definition)
    {
        $output = clone $object;
        foreach ($definition as $key => $node) {
            if (isset($node['required'])) {
                if ((!$node['required']) && (!isset($output->{$key}))) {
                    $output->{$key} = $node['default'];
                }
            } else {
                if (!isset($output->{$key})) {
                    $output->{$key} = new stdClass();
                }
                $output->{$key} = $this->populateObjectItems($output->{$key}, $node);
            }
        }
        return $output;
    }
35498
protected function _init($definition=null)
    {

        if (!is_null($definition)) {
            $this->_packageXml = simplexml_load_string($definition);
        } else {
            $packageXmlStub = <<<END
<?xml version="1.0"?>
<package>
    <name />
    <version />
    <stability />
    <license />
    <channel />
    <extends />
    <summary />
    <description />
    <notes />
    <authors />
    <date />
    <time />
    <contents />
    <compatible />
    <dependencies />
</package>
END;
            $this->_packageXml = simplexml_load_string($packageXmlStub);
        }
        return $this;
    }
546311
private function hydrateDefinitionClass(Definition $definition, array &$definitionArray)
    {
        if (null !== $definition->getClass()) {
            $definitionArray['class'] = $definition->getClass();
        }
    }
1296588
static function get($key, $def = NULL)
	{
		if(array_key_exists($key, $GLOBALS['cms']['config']))
			return  $GLOBALS['cms']['config'][$key];

		return $def;
	}
325285
public function getDefinitionCache()
	{
		if( !isset($this->definitionCache)) {
			return null;
		}
		if( ! isset($this->_dc)) {
			if( is_string($this->definitionCache)) {
				$this->_dc = Yii::$app->get($this->definitionCache);
			} elseif( is_array($this->definitionCache)) {
				$this->_dc = Yii::createObject($this->definitionCache);
			}  elseif( is_object($this->definitionCache)) {
				$this->_dc = $this->definitionCache;
			}  else {
				throw new InvalidConfigException('invalid "definitionCache" attribute : string or object expected');
			}
			if( ! $this->_dc instanceof yii\caching\Cache ) {
				throw new InvalidConfigException('the workflow definition cache must implement the yii\caching\Cache interface');
			}
		}
		return $this->_dc;
	}
875036
function (def) {
                var bp = def.$package; // beans package
                Aria.$classes.push({
                    $classpath : bp
                });
                this.__waitingBeans[bp] = def;
                var dep = [];

                // load missing dependencies

                // add $dependencies
                var dependencies = def.$dependencies || [];
                if (dependencies.length) {
                    dep = dep.concat(dependencies);
                }

                // add bean definition from namespaces
                for (var key in def.$namespaces) {
                    if (def.$namespaces.hasOwnProperty(key)) {
                        dep.push(def.$namespaces[key]);
                    }
                }

                return Aria.loadOldDependencies({
                    classpaths : {
                        "JS" : dep
                    },
                    classDefinition : def,
                    complete : {
                        scope : this,
                        fn : this.__loadBeans,
                        args : [bp]
                    }
                });
            }
39863
private function isTrivialInstance(Definition $definition)
    {
        if ($definition->isSynthetic() || $definition->getFile() || $definition->getMethodCalls() || $definition->getProperties() || $definition->getConfigurator()) {
            return false;
        }
        if ($definition->isDeprecated() || $definition->isLazy() || $definition->getFactory() || 3 < count($definition->getArguments())) {
            return false;
        }

        foreach ($definition->getArguments() as $arg) {
            if (!$arg || $arg instanceof Parameter) {
                continue;
            }
            if (is_array($arg) && 3 >= count($arg)) {
                foreach ($arg as $k => $v) {
                    if ($this->dumpValue($k) !== $this->dumpValue($k, false)) {
                        return false;
                    }
                    if (!$v || $v instanceof Parameter) {
                        continue;
                    }
                    if ($v instanceof Reference && $this->container->has($id = (string) $v) && $this->container->findDefinition($id)->isSynthetic()) {
                        continue;
                    }
                    if (!is_scalar($v) || $this->dumpValue($v) !== $this->dumpValue($v, false)) {
                        return false;
                    }
                }
            } elseif ($arg instanceof Reference && $this->container->has($id = (string) $arg) && $this->container->findDefinition($id)->isSynthetic()) {
                continue;
            } elseif (!is_scalar($arg) || $this->dumpValue($arg) !== $this->dumpValue($arg, false)) {
                return false;
            }
        }

        if (false !== strpos($this->dumpLiteralClass($this->dumpValue($definition->getClass())), '$')) {
            return false;
        }

        return true;
    }
478118
public function addDefinition(string $name, array $definition)
    {
        if (isset($this->_definition[$name])) {
            throw new Exception('Definition for "' . $name . '" already exists');
        }

        $this->_definition[$name] = $definition;

        return $this;
    }