platform/api/symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.yaml

81 lines
3.5 KiB
YAML
Raw Normal View History

2024-09-02 17:44:11 +00:00
name: EnvPlaceholderParameterBag
class_comment: '# * @author Nicolas Grekas <p@tchwork.com>'
dependencies:
- name: InvalidArgumentException
type: class
source: Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- name: RuntimeException
type: class
source: Symfony\Component\DependencyInjection\Exception\RuntimeException
properties: []
methods:
- name: getEnvPlaceholderUniquePrefix
visibility: public
parameters: []
comment: "# * @author Nicolas Grekas <p@tchwork.com>\n# */\n# class EnvPlaceholderParameterBag\
\ extends ParameterBag\n# {\n# private string $envPlaceholderUniquePrefix;\n#\
\ private array $envPlaceholders = [];\n# private array $unusedEnvPlaceholders\
\ = [];\n# private array $providedTypes = [];\n# \n# private static int $counter\
\ = 0;\n# \n# public function get(string $name): array|bool|string|int|float|\\\
UnitEnum|null\n# {\n# if (str_starts_with($name, 'env(') && str_ends_with($name,\
\ ')') && 'env()' !== $name) {\n# $env = substr($name, 4, -1);\n# \n# if (isset($this->envPlaceholders[$env]))\
\ {\n# foreach ($this->envPlaceholders[$env] as $placeholder) {\n# return $placeholder;\
\ // return first result\n# }\n# }\n# if (isset($this->unusedEnvPlaceholders[$env]))\
\ {\n# foreach ($this->unusedEnvPlaceholders[$env] as $placeholder) {\n# return\
\ $placeholder; // return first result\n# }\n# }\n# if (!preg_match('/^(?:[-.\\\
w\\\\\\\\]*+:)*+\\w*+$/', $env)) {\n# throw new InvalidArgumentException(\\sprintf('The\
\ given env var name \"%s\" contains invalid characters (allowed characters: letters,\
\ digits, hyphens, backslashes and colons).', $name));\n# }\n# if ($this->has($name)\
\ && null !== ($defaultValue = parent::get($name)) && !\\is_string($defaultValue))\
\ {\n# throw new RuntimeException(\\sprintf('The default value of an env() parameter\
\ must be a string or null, but \"%s\" given to \"%s\".', get_debug_type($defaultValue),\
\ $name));\n# }\n# \n# $uniqueName = hash('xxh128', $name.'_'.self::$counter++);\n\
# $placeholder = \\sprintf('%s_%s_%s', $this->getEnvPlaceholderUniquePrefix(),\
\ strtr($env, ':-.\\\\', '____'), $uniqueName);\n# $this->envPlaceholders[$env][$placeholder]\
\ = $placeholder;\n# \n# return $placeholder;\n# }\n# \n# return parent::get($name);\n\
# }\n# \n# /**\n# * Gets the common env placeholder prefix for env vars created\
\ by this bag."
- name: getEnvPlaceholders
visibility: public
parameters: []
comment: '# * Returns the map of env vars used in the resolved parameter values
to their placeholders.
# *
# * @return string[][] A map of env var names to their placeholders'
- name: getUnusedEnvPlaceholders
visibility: public
parameters: []
comment: null
- name: clearUnusedEnvPlaceholders
visibility: public
parameters: []
comment: null
- name: mergeEnvPlaceholders
visibility: public
parameters:
- name: bag
comment: '# * Merges the env placeholders of another EnvPlaceholderParameterBag.'
- name: setProvidedTypes
visibility: public
parameters:
- name: providedTypes
comment: '# * Maps env prefixes to their corresponding PHP types.'
- name: getProvidedTypes
visibility: public
parameters: []
comment: '# * Gets the PHP types corresponding to env() parameter prefixes.
# *
# * @return string[][]'
- name: resolve
visibility: public
parameters: []
comment: null
traits:
- Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- Symfony\Component\DependencyInjection\Exception\RuntimeException
interfaces: []