Returns the models definition

@param array $definitions
@return array
@throws Exception
492975
private function parseModels($definitions)
    {
        $ret = [];
        foreach ($definitions as $definition)
        {
            $ret[$definition] = $this->parseModel($definition);
        }
        return $ret;
    }
142438
protected static function extractExtensions(\stdClass $definition): array
    {
        $extensions = [];
        foreach ($definition as $attribute => $value) {
            if (0 === strpos($attribute, 'x-')) {
                $extensions[substr($attribute, 2)] = $value;
                unset($definition->$attribute);
            }
        }

        return $extensions;
    }
595961
private function namespaceDefinitions(array $definitions, Endpoint $endpoint): array
    {
        $namespacedDefinitions = [];
        /** @var DefinitionInterface $definition */
        foreach ($definitions as $definition) {
            if (!$definition->hasMeta('namespace') || !$definition->getMeta('namespace')) {
                $namespacedDefinitions[$definition->getName()] = $definition;
                continue;
            }

            $root = null;
            $parent = null;
            $namespaceConfig = $definition->getMeta('namespace');
            $namespacePath = $namespaceConfig['namespace'] ?? null;
            if ($namespacePath) {
                $querySuffix = $this->globalConfig['nodes']['query_suffix'] ?? 'Query';
                $mutationSuffix = $this->globalConfig['nodes']['mutation_suffix'] ?? 'Mutation';
                $subscriptionSuffix = $this->globalConfig['nodes']['subscription_suffix'] ?? 'Subscription';
                $namespaces = explode('/', $namespacePath);
                foreach ($namespaces as $namespace) {
                    $name = lcfirst($namespace);
                    $suffix = $querySuffix;
                    if ($definition instanceof MutationDefinition) {
                        $suffix = $mutationSuffix;
                    }
                    if ($definition instanceof SubscriptionDefinition) {
                        $suffix = $subscriptionSuffix;
                    }
                    $typeName = ucfirst($name).$suffix;
                    if (!$root) {
                        if (isset($namespacedDefinitions[$name])) {
                            $root = $namespacedDefinitions[$name];
                        } else {
                            $root = $this->createRootNamespace($definition, $name, $typeName, $endpoint);
                        }
                        $parent = $endpoint->getType($root->getType());
                        $namespacedDefinitions[$root->getName()] = $root;
                    } else {
                        $parent = $this->createChildNamespace($parent, $name, $typeName, $endpoint);
                    }
                }
                if ($alias = $namespaceConfig['alias'] ?? null) {
                    $definition->setName($alias);
                }
                $this->addDefinitionToNamespace($parent, $definition, $definition->getName());
                continue;
            }

            if ($bundle = $namespaceConfig['bundle'] ?? null) {
                $bundleQuerySuffix = $this->globalConfig['bundle']['query_suffix'] ?? 'BundleQuery';
                $bundleMutationSuffix = $this->globalConfig['bundle']['mutation_suffix'] ?? 'BundleMutation';
                $bundleSubscriptionSuffix = $this->globalConfig['bundle']['subscription_suffix'] ?? 'BundleSubscription';
                $name = lcfirst($bundle);
                $suffix = $bundleQuerySuffix;
                if ($definition instanceof MutationDefinition) {
                    $suffix = $bundleMutationSuffix;
                }
                if ($definition instanceof SubscriptionDefinition) {
                    $suffix = $bundleSubscriptionSuffix;
                }
                $typeName = ucfirst($name).$suffix;
                $root = $this->createRootNamespace($definition, $name, $typeName, $endpoint);
                $parent = $endpoint->getType($root->getType());
            }

            if ($nodeName = $namespaceConfig['node'] ?? null) {
                if ($endpoint->hasTypeForClass($nodeName)) {
                    $nodeName = $endpoint->getTypeForClass($nodeName);
                }

                $name = Inflector::pluralize(lcfirst($nodeName));

                $querySuffix = $this->globalConfig['nodes']['query_suffix'] ?? 'Query';
                $mutationSuffix = $this->globalConfig['nodes']['mutation_suffix'] ?? 'Mutation';
                $subscriptionSuffix = $this->globalConfig['nodes']['subscription_suffix'] ?? 'Subscription';

                $suffix = $querySuffix;
                if ($definition instanceof MutationDefinition) {
                    $suffix = $mutationSuffix;
                }
                if ($definition instanceof SubscriptionDefinition) {
                    $suffix = $subscriptionSuffix;
                }

                $typeName = ucfirst($nodeName).$suffix;
                if (!$root) {
                    $root = $this->createRootNamespace($definition, $name, $typeName, $endpoint);
                    $parent = $endpoint->getType($root->getType());
                } elseif ($parent) {
                    $parent = $this->createChildNamespace($parent, $name, $typeName, $endpoint);
                }

                if ($alias = $namespaceConfig['alias'] ?? null) {
                    $originName = $definition->getName();
                    $definition->setName($alias);
                } else {
                    //remove node suffix on namespaced definitions
                    $originName = $definition->getName();
                    $definition->setName(preg_replace(sprintf("/(\w+)%s$/", $nodeName), '$1', $definition->getName()));
                    $definition->setName(preg_replace(sprintf("/(\w+)%s$/", Inflector::pluralize($nodeName)), '$1', $definition->getName()));
                }
            }

            if ($root && $parent) {
                $this->addDefinitionToNamespace($parent, $definition, $originName);
                $namespacedDefinitions[$root->getName()] = $root;
            } else {
                $namespacedDefinitions[$definition->getName()] = $definition;
            }
        }

        return $namespacedDefinitions;
    }
680693
public function resolver($definition, array $args = [])
    {
        if ($definition instanceof Closure) {
            $resolvedDefinition = call_user_func_array($definition, $args);
        } elseif (is_object($definition)) {
            $resolvedDefinition = $definition;
        } elseif (is_string($definition)) {
            if (class_exists($definition)) {
                $reflectionObj = new ReflectionClass($definition);
                $resolvedDefinition = $reflectionObj->newInstanceArgs($args);
            } else {
                throw new Exception(sprintf('Class "%s" does not exist.', $definition));
            }
        } elseif (is_array($definition)) {
            $resolvedDefinition = self::fromArray($definition);
        } else {
            throw new Exception(sprintf('Definition type "%s" does not support.', gettype($definition)));
        }

        return $resolvedDefinition;
    }
1203276
public static function run($definition) {
		$filterCollection = ScenarioHelper::forgeCollection($definition['filters']);
		$config = ScenarioHelper::runAll($filterCollection, []);
		$definition['commands'] = Helper::assignAttributesForList($definition['commands'], [
			'env' => $config,
		]);
		$commandCollection = ScenarioHelper::forgeCollection($definition['commands']);
		ScenarioHelper::runAll($commandCollection);
		return $config;
	}
38773
private function filterOutAbstractDefinitions(array $definitions): array
    {
        foreach ($definitions as $key => $definition) {
            if ($definition->isAbstract()) {
                unset($definitions[$key]);
            }
        }

        return $definitions;
    }
1164483
public static function loadDefinition(DefinitionInterface $definition): Graph
    {
        $graph = new Graph($definition);

        foreach ($definition->processes() as $id => $def) {
            $graph->addNode($id, $def[Net::COMPONENT]);
        }

        foreach ($definition->initializers() as $initializer) {
            $graph->addInitial(
                $initializer[Net::DATA],
                $initializer[Net::CONNECTION_TARGET][Net::PROCESS],
                $initializer[Net::CONNECTION_TARGET][Net::PORT]
            );
        }

        foreach ($definition->connections() as $conn) {
            $graph->addEdge(
                $conn[Net::CONNECTION_SOURCE][Net::PROCESS],
                $conn[Net::CONNECTION_SOURCE][Net::PORT],
                $conn[Net::CONNECTION_TARGET][Net::PROCESS],
                $conn[Net::CONNECTION_TARGET][Net::PORT]
            );
        }

        return $graph;
    }
491762
public function configure(...$definitions): ContainerConfiguration
    {
        $builder = new ContainerBuilder(ContainerConfiguration::class);

        $builder->useAutowiring(false)->useAnnotations(false)->ignorePhpDocErrors(false);

        $wiring = $this->config[WIRING] ?? null;
        if (fn\hasValue($wiring, [WIRING\REFLECTION, WIRING\AUTO])) {
            $builder->useAutowiring(true);
        } else if ($wiring === WIRING\STRICT) {
            $builder->useAnnotations(true)->ignorePhpDocErrors(false);
        } else if ($wiring === WIRING\TOLERANT) {
            $builder->useAnnotations(true)->ignorePhpDocErrors(true);
        }

        empty($this->config[CACHE]) || $builder->enableDefinitionCache();
        empty($this->config[PROXY]) || $builder->writeProxiesToFile(true, $this->config[PROXY]);
        empty($this->config[COMPILE]) || $builder->enableCompilation($this->config[COMPILE]);
        $this->container && $builder->wrapContainer($this->container);

        foreach ($definitions as $definition) {
            $builder->addDefinitions($definition);
        }

        /** @noinspection PhpUnhandledExceptionInspection */
        /** @noinspection PhpIncompatibleReturnTypeInspection */
        $built = $builder->build();
        return $built instanceof ContainerConfiguration
            ? $built
            : new ContainerConfiguration($built);
    }
1007482
public function listGetConfig($definition = null)
    {
        if (!$definition) {
            $definition = $this->primaryDefinition;
        }

        if (!$config = array_get($this->listConfig, $definition)) {
            $config = $this->listConfig[$definition] = $this->makeConfig($this->listDefinitions[$definition], $this->requiredConfig);
        }

        return $config;
    }
228706
public function get_store_instances_in_use(cache_definition $definition) {
        $id = $definition->get_id();
        if (!isset($this->definitionstores[$id])) {
            return array();
        }
        return $this->definitionstores[$id];
    }
974820
private function normalizeDefinition($definition)
    {
        if (!is_array($definition)) {
            if (!is_string($definition) || strpos($definition, 'shared:files') === false) {
                throw new \RuntimeException('Failed to parse mount definition: ' . json_encode($definition));
            }
            $definition = [
                'source' => 'local',
                'source_path' => str_replace('shared:files', '', $definition),
            ];
        } elseif (!isset($definition['source'])) {
            throw new \InvalidArgumentException('Invalid mount definition: ' . json_encode($definition));
        }
        if (isset($definition['source_path'])) {
            $definition['source_path'] = $this->normalizeRelativePath($definition['source_path']);
        }

        return $definition;
    }
1025864
private function getInlinedDefinitions(Definition $definition)
    {
        if (false === $this->inlinedDefinitions->contains($definition)) {
            $definitions = array_merge(
                $this->getDefinitionsFromArguments($definition->getArguments()),
                $this->getDefinitionsFromArguments($definition->getMethodCalls()),
                $this->getDefinitionsFromArguments($definition->getProperties()),
                $this->getDefinitionsFromArguments(array($definition->getConfigurator())),
                $this->getDefinitionsFromArguments(array($definition->getFactory()))
            );

            $this->inlinedDefinitions->offsetSet($definition, $definitions);

            return $definitions;
        }

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

        return $this->dictionaryBuilders->get($typeName);
    }
602649
private function getCompilerPass(Definition $definition)
    {
        $driver = $this->getResourceDriver($definition);

        if ($driver === null) {
            return;
        }

        $class = $this->getCompilerPassClass($driver);
        $method = $this->getCompilerPassMethod($this->getResourceDriverMappingFormat($definition));
        $path = $this->getResourceDriverMappingPath($definition);
        $model = $this->getResourceModel($definition);

        return $class::$method([$path => ClassUtils::getRealNamespace($model)], []);
    }
228052
public function getModels($properties = array('*'))
    {
        // First, we will simply get the raw results from the query builders which we
        // can use to populate an array with Eloquent models. We will pass columns
        // that should be selected as well, which are typically just everything.
        $results = $this->query->get($properties);

        // Once we have the results, we can spin through them and instantiate a fresh
        // model instance for each records we retrieved from the database. We will
        // also set the proper connection name for the model after we create it.
        return $this->resultsToModels($this->model->getConnectionName(), $results, $properties);
    }
327692
public function getDefinitions()
    {
        if (false !== $this->definitions) {
            return $this->definitions;
        }

        $config = $this->metadataLoader->load($this->resource, $this->resourceType);

        if (null === $config) {
            return [];
        }

        return $this->definitions = $config;
    }
625305
protected function parseSortDefinition($definition) {
		$definition = trim($definition);
		$spacePos   = strrpos($definition, ' ');
		
		if ($spacePos === false) {
			return [$definition, SORT_ASC];
		}
		
		$property  = substr($definition, 0, $spacePos);
		$direction = substr($definition, $spacePos);
		$direction = strtolower(ltrim($direction));

		if ($direction === self::SORT_ASC) {
			return [$property, SORT_ASC];
		}
		
		if ($direction === self::SORT_DESC) {
			return [$property, SORT_DESC];
		}
		
		throw new Exception('Unknown sort direction: "' . $direction . '"');
	}