*/ class DefinitionArray implements DefinitionSource, MutableDefinitionSource { const WILDCARD = '*'; /** Matches anything except "\". */ const WILDCARD_PATTERN = '([^\\\\]+)'; /** * DI definitions in a PHP array. * @var array */ private $definitions = []; /** * Cache of wildcard definitions. * @var array|null */ private $wildcardDefinitions; /** @var DefinitionNormalizer */ private $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; $autowiring = $autowiring ?: new NoAutowiring; $this->normalizer = new DefinitionNormalizer($autowiring); } /** * @param array $definitions DI definitions in a PHP array indexed by the definition name. */ public function addDefinitions(array $definitions) { 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; } /** * {@inheritdoc} */ public function addDefinition(Definition $definition) { $this->definitions[$definition->getName()] = $definition; // Clear cache $this->wildcardDefinitions = null; } public function getDefinition(string $name) { // Look for the definition by name if (array_key_exists($name, $this->definitions)) { $definition = $this->definitions[$name]; $definition = $this->normalizer->normalizeRootDefinition($definition, $name); return $definition; } // Build the cache of wildcard definitions if ($this->wildcardDefinitions === null) { $this->wildcardDefinitions = []; foreach ($this->definitions as $key => $definition) { if (strpos($key, self::WILDCARD) !== false) { $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); $definition = $this->normalizer->normalizeRootDefinition($definition, $name, $matches); return $definition; } } return null; } public function getDefinitions(): array { // Return all definitions except wildcard definitions $definitions = []; foreach ($this->definitions as $key => $definition) { if (strpos($key, self::WILDCARD) === false) { $definitions[$key] = $definition; } } return $definitions; } } __halt_compiler();----SIGNATURE:----fe9Vk6H7ZTQGemA+AFHSFqKYN5izl80nWk2eQg+u/aexfBYENFB0AhoZaL5nSsQF3NA7FKVxhwT2Sg/8VbyyF9Nuh6Hh6rdL4375tKI6yn9pk8hs00XFp1edwvSbxi7pCpTMLg7+g7l4hvn87k8TTAitqZZwSxiy0ID58cIp8gQ13MFxHOIYdQ+Smgp1+A5IvYZk67+0XPmKOuRk46XTk4UYZ1vQhGrSlzsZnl3tXzT+4sq3hloRHMxF+vMjh7j79OfXfGXUosbRGLaz4zBQFIM+m34yqLLgJpYRFyRm9yutikB88DyK8IgO+IOcCqxFBZqrLKdxj2zgjtWsMMlXTGgCWDLmil0uUt0nDjha9CILmn5LAKcVGSI8BNwJpce7yvvnCnlYJ5ZTl+JtM62KlwGvKI+YNBQqrHz7ta+vVXaY+jstC3yyfY5nS7HEBo8QlGUkOdA1Fb5t9Buvdi5aHi9AD7g2CCGj+SR4+KI50QxXZzP9Oc8EslJLWabDSdB6aLZ7gR62U7GpuLzhuprmsK8wSF5q/CX/7RIWFu2I4SuReC7q13u9d30ZsvHP0crJKErOEQ2GD4p1Z0n20CRFEdUoHocyC2Gf6n+o726ubjgkKAVIdUhOoWtgEm3IVjO2NGHl/nYop/rXY2YSvj5cgLcSmqEbM8Q/5JBXPqYsjFY=----ATTACHMENT:----OTkxNjI3NzEwNzgyNDk5IDE0OTkyNjE0NTM2NDM2MSAyNzg1NTQ5NDI0NTk4NDk1