*/ class DefinitionArray implements DefinitionSource, MutableDefinitionSource { public const WILDCARD = '*'; /** Matches anything except "\". */ private const WILDCARD_PATTERN = '([^\\\]+)'; /** DI definitions in a PHP array. */ private array $definitions; /** Cache of wildcard definitions. */ private ?array $wildcardDefinitions = null; private DefinitionNormalizer $normalizer; public function __construct(array $definitions = [], ?Autowiring $autowiring = null) { if (isset($definitions[0])) { throw new \Exception('The PHP-DI definition is not indexed by an entry name in the definition array'); } $this->definitions = $definitions; $this->normalizer = new DefinitionNormalizer($autowiring ?: new NoAutowiring); } /** * @param array $definitions DI definitions in a PHP array indexed by the definition name. */ public function addDefinitions(array $definitions): void { if (isset($definitions[0])) { throw new \Exception('The PHP-DI definition is not indexed by an entry name in the definition array'); } // The newly added data prevails // "for keys that exist in both arrays, the elements from the left-hand array will be used" $this->definitions = $definitions + $this->definitions; // Clear cache $this->wildcardDefinitions = null; } public function addDefinition(Definition $definition): void { $this->definitions[$definition->getName()] = $definition; // Clear cache $this->wildcardDefinitions = null; } public function getDefinition(string $name): Definition|null { // Look for the definition by name if (array_key_exists($name, $this->definitions)) { $definition = $this->definitions[$name]; return $this->normalizer->normalizeRootDefinition($definition, $name); } // Build the cache of wildcard definitions if ($this->wildcardDefinitions === null) { $this->wildcardDefinitions = []; foreach ($this->definitions as $key => $definition) { if (str_contains($key, self::WILDCARD)) { $this->wildcardDefinitions[$key] = $definition; } } } // Look in wildcards definitions foreach ($this->wildcardDefinitions as $key => $definition) { // Turn the pattern into a regex $key = preg_quote($key, '#'); $key = '#^' . str_replace('\\' . self::WILDCARD, self::WILDCARD_PATTERN, $key) . '#'; if (preg_match($key, $name, $matches) === 1) { array_shift($matches); return $this->normalizer->normalizeRootDefinition($definition, $name, $matches); } } return null; } public function getDefinitions(): array { // Return all definitions except wildcard definitions $definitions = []; foreach ($this->definitions as $key => $definition) { if (! str_contains($key, self::WILDCARD)) { $definitions[$key] = $definition; } } return $definitions; } }__halt_compiler();----SIGNATURE:----Fsc14ILTcIa4jgq5YgG3CJYoVKjGQH1I0Fd30oXKDik2yZCifNR+9rkOsj2JHNEzj6BqKuzkDQdgEnaIA79ygvW4iRwCsz5gFD+4Hsf1UonHhKs6A4tildVPEiYGNv3NozWA6KHL72lwaRdcoiAyRf0AUB+anpxRL/oTdohuV4FBC6FYqh/Qzdth/FbVhfbW6T006SuN77mdCUVKjHAWRdjf/7ANNvtD49YN5aFPAC8hpnzSpN3DahzuPUV4t3JxmFh+YjQiXgj4k0+L7LoRmrIIKV9q+LjK26YRhr3KSgO39Ol72UndDS9Yuv11XnAe4/+j0JKWb+jJ0n0gLdWSBjxlyXYgwdXaO8dEvbmVWyc9HhZFq3fKouBEd+H5SYtqy0OWxQgD8RMpQ8BPNb2gcYlYGAcEQ9AN9LYt7/d3EIAnmJFbMZ89lvIk8flw921LLar1ENyv1FUKG9XYEkJ7I446cA6FTS1L8dTpsuEYpGD10ASzcL+rZc3Sq2u/ookhk2FPRpiTTZUnjuB0HbraOvdUaJ3BHXbjndI/AsQqSDWZEzZZMk/qCzOtWX+pqlTGlWAvQSEUN5E6DEuzLllRZ9r8eTeuZD8+Dp1bd3rf+0Q744c+UomgBs3D4y31IkXLwYYKNCWIAgi/gBz8ZbSgRpKnCexdka0hjrPk4bxoxhw=----ATTACHMENT:----MzMzNjU4OTkxMzgyMTQ4IDcyNzMzMzkzODgwNzY3NTcgMzE3MzEyMzQ4ODU5OTIwNA==