*/ class SourceChain implements DefinitionSource, MutableDefinitionSource { /** @var DefinitionSource[] */ private $sources; /** @var DefinitionSource */ private $rootSource; /** @var MutableDefinitionSource|null */ private $mutableSource; /** * @param DefinitionSource[] $sources */ public function __construct(array $sources) { // We want a numerically indexed array to ease the traversal later $this->sources = array_values($sources); $this->rootSource = $this; } /** * {@inheritdoc} * * @param int $startIndex Use this parameter to start looking from a specific * point in the source chain. */ public function getDefinition(string $name, int $startIndex = 0) { $count = count($this->sources); for ($i = $startIndex; $i < $count; ++$i) { $source = $this->sources[$i]; $definition = $source->getDefinition($name); if ($definition) { if ($definition instanceof ExtendsPreviousDefinition) { $this->resolveExtendedDefinition($definition, $i); } return $definition; } } return null; } public function getDefinitions(): array { $names = []; foreach ($this->sources as $source) { $names = array_merge($names, $source->getDefinitions()); } $names = array_keys($names); $definitions = array_combine($names, array_map(function (string $name) { return $this->getDefinition($name); }, $names)); return $definitions; } public function addDefinition(Definition $definition) { if (! $this->mutableSource) { throw new \LogicException("The container's definition source has not been initialized correctly"); } $this->mutableSource->addDefinition($definition); } private function resolveExtendedDefinition(ExtendsPreviousDefinition $definition, int $currentIndex) { // Look in the next sources only (else infinite recursion, and we can only extend // entries defined in the previous definition files - a previous == next here because // the array was reversed ;) ) $subDefinition = $this->getDefinition($definition->getName(), $currentIndex + 1); if ($subDefinition) { $definition->setExtendedDefinition($subDefinition); } } public function setMutableDefinitionSource(MutableDefinitionSource $mutableSource) { $this->mutableSource = $mutableSource; array_unshift($this->sources, $mutableSource); } } __halt_compiler();----SIGNATURE:----AFjuar+43T8S1PwqBAe7vBt7vP2+77V8gpmDZpqYPDJJSoZdfuXoiztQInp/K8xSZWlrqma5CQv8IHP64+kUmilYzrSwfms5jX6c37/oQaZ/aGvi4SF6Zcn3/4+iPwwBKTPFLz7yV9t2g3tR47M92BPybey8Tac9zIuaNLxjwpSTrTmO3JGWv1lfjsibE3C38I0Oeqxo9zh8+RYaRFbuSLcAt4p/qvgRghr6Wx84bHsQwc5Lcl9aEtZTDNBEoijOFV0QFFvHt+pBjTBlH8DHBTi0WfUI8dJ7ZgD9f+VoMro/txKPbDCj3z/UYJcL6fSyGtXY5EHKxH3sYOwVKQAIHvi+EvsDnRBYb3WxRbDyipjplr7gTQLuqK5HY551Zjg9ve9Qp+8hvgsAn1WJO5n1m5tPBGeOXxjro7sTwcQSSyRtj2TyjG3uS8BVBvfjKCoazGakbBbyf4pOCmar6iuyqILxghow1awCbOdO2yNnahli7EBIF0wATFWJczfgfZAaj/lMgSIke89wkaZo+i7c2AlOYwuFzHbdeiD4bVAVT00Saj9xSaqD5XLjfnf2Wm03iAmE7vY3gnwP+CfK0gjt8vBZ7zwGSApG8GhiQ6ZWjjoXr18i8z1tnQW4+OjtsRvcVuHd/Fyp9qk/85Ij463MtRcbEXJXFh4VxI67imW1jLg=----ATTACHMENT:----MjY2ODczMjE3NTAxOTU2IDcxMjU4OTk4ODY0MDEzNTkgMjY0NzU5NjMzNjkwOTU0MQ==