*/ 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:----wnDz4iHzvDdjj0eMTsb0/QqFaVnl0Sf4I2crQrpnCFbccGRAgUFWI7erDpEgwtQwfwgTcO8lI+Cc75H88TnyO7bxd35PQWoiUkRsMGtu87pH2PjaOB+k8/8WRUiXcTEwam+y28VwVL5XS3OVxa9ALdySvFnkNVoQkJkKynDEk89VPMUswA0c2A6+5Z3s0rb0Cwh9Fcm5K2MXHn9lAkseWi9UylwtE72uTbjHtRriU2gus7vEOk873D3F7sBwcOqbW9iQsG08Jut5JeJd6CTLFXVzJqZY/UFUnxuZY1Svdqwc0NUBinChwRLpmFE4OysxbgIOf2iWba+QjmKw18UgKPMVieTjUgIYET+76IaR7DpSxIhPC5I8IBDTkWPo7s19pPP2IFnm6L+ucgDZQo0PXa3FEIfoApKFifknZUEHf7xqAIS0EuYTULi6BKCdAc8UJmXBuYgv3E7sYxxzcq5IHw/qG88Ww9yjFw8DeNXPCUZtgVJ8IXNXUvtQWBIKTDAPkJ4hyc2CqnAV8+0mxzaW36eACQ7zmSlIGBmvgvrGOsx8oED1kyJrbd03c2aWHThpdMOe2Le+FvebA7FAwkOIWDwEo4296woP/X9ilfYWnZ1EQCYjKoavbm44afZtm2O9XTi9aOjxFkVkaJ1M/n2D4sJ4RAyAAcBzd4mzhWjP8kg=----ATTACHMENT:----NDIzOTIyMDU1NTUzMzQyOSA4NTkzNzg5ODYwNDE1MTYwIDMxNTc1MjcwNzI3MjY5ODU=