*/ class SourceChain implements DefinitionSource, MutableDefinitionSource { private ?MutableDefinitionSource $mutableSource; /** * @param list $sources */ public function __construct( private array $sources, ) { } /** * @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): Definition|null { $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 { $allDefinitions = array_merge(...array_map(fn ($source) => $source->getDefinitions(), $this->sources)); /** @var string[] $allNames */ $allNames = array_keys($allDefinitions); $allValues = array_filter(array_map(fn ($name) => $this->getDefinition($name), $allNames)); return array_combine($allNames, $allValues); } public function addDefinition(Definition $definition): void { 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): void { $this->mutableSource = $mutableSource; array_unshift($this->sources, $mutableSource); } }__halt_compiler();----SIGNATURE:----f5OLm4CtM/A6ZBh3KVUSMG9kCJkaXnXs6YoySnH5g0tNzvI1hyfatXyqAh0EA9TwgYRjueHIyMAjGI5531f+SrYkCmrfs3lGiv0Y+cmS5D88khxIcumGvIkO7ivd5HUpHINOmjHdHMVLrxa8BWn8aQ7oWVPlgKjBFUFDRFFgcs2ob/3keCZiPJGBScBE7bhx4B7V9kh2h+SxpUMYORyv/oyE7okfVNK8OVeXfrrT3ivk3cS639vCM14D51itbDkYu/+xf73v3CBrwbQeVMmT2dFIl6N0ahPJAgNMMD8GV9ydWCeIWrPr1KUUchKaZoniSbkBtViy60RqsRigbGhm5ePd12BU7GP6nh6U8Dz7vTHOecEX0y9GMV1xkOgc5b3UhwdPy9I9dwCDj4b3tWtjL21QD8UdqbxxBFBgHzL+c1wx8385nGLqyxe+cFgaSeIp7dqoETVGwLqLn3fGkGpdASNc+vwEWhepI3rAR2m4eMhB0IMtt7BeVpbzjU+wnYzVmUOlPo9qPDietPAMXnU849dRc+WIK/IR4G/E6PlrRhpVmZvyU7X027ILGUCf0VMOvKZCyGaMfZB61MtY8Z3I2fiCHo+dUFQKdcxlpipCCJ0jE04LE9oP5XCf31c/JSbw8Z/VJlp1itohdvQc+wtFRo4S8mnv+uquI7ZLJRfgUZo=----ATTACHMENT:----MzY3NzgwODk2NTI0Mzc1NiAxOTA3NDI3MjAwNjU3ODU2IDg0ODA2MjUxNjUyODI0NjE=