*/ 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:----QtvUKu0A55PQaU0yxlqyWuQhI5yCVF84K6sKd20ARFujn8B6/sBQVB8XLiiqeaCT9I8ILLutChSBKiSu//DlN/5JkXNIbKWhbzMgPogDnrGqv3LOUev5nSAvEIu11deRlXg61sFUTxonUWc2ZFX7FivH8uVJLIfSazg+JWxNDqL6T+8Ylt4kQ42TY2h5amR45YYJUj8gg8yj/X1bG5UFoC0VYEVh/hTIqXRod4MvGUgHP9r5qveF7hT8oQzPxYUnhvzXsDFi2Wu6XdRilEHu9uxG3jRtEfM7yb0Qavi1yROq694YChepwfuzuYYiQuo9qMOF5YPqJCJKtcagnIJ47rZ6a90CnsBOX1Z6aYdJv4K2XvzX3Aner9JniYLhSiT2WV+rfdVl+Wv/6nys1kTmvo1x8v/fzo/r7hCW99n0a9F2Y6OBbwpFPR6E21CyUktJK6XIk/6EWrbV5iAbTSFC4RMdBS0o6JCpxbu8WzAwGAO//J1twycK+uleyqMp20jUr+/MHCZO1zB9ovGGNw11Als4D2p34sArePMXMUj6GsNBRb0Ayes3K4D2x7v3BjlEa9yeiqkcLHv74msYunPPBAPImsawr67efotmQfdYtn3ieYd5SOyiOwU/dv5q5cplPPGNmeN7zEailDO1t8ZyuYCj4cPf1GCrPIU71Ka2gaU=----ATTACHMENT:----MjU1NDE1NjM1OTE1NzU2NSA2NjYxNTA4MzcyMDcxOTQyIDIyMTA2NzgxNDUyMjYwMjI=