aboutsummaryrefslogtreecommitdiff
path: root/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag')
-rw-r--r--srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ContainerBag.php51
-rw-r--r--srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ContainerBagInterface.php57
-rw-r--r--srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php173
-rw-r--r--srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php68
-rw-r--r--srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php289
-rw-r--r--srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ParameterBagInterface.php115
6 files changed, 753 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ContainerBag.php b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ContainerBag.php
new file mode 100644
index 0000000..7671dfc
--- /dev/null
+++ b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ContainerBag.php
@@ -0,0 +1,51 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\ParameterBag;
+
+use Symfony\Component\DependencyInjection\Container;
+
+/**
+ * @author Nicolas Grekas <p@tchwork.com>
+ */
+class ContainerBag extends FrozenParameterBag implements ContainerBagInterface
+{
+ private $container;
+
+ public function __construct(Container $container)
+ {
+ $this->container = $container;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function all()
+ {
+ return $this->container->getParameterBag()->all();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get($name)
+ {
+ return $this->container->getParameter($name);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function has($name)
+ {
+ return $this->container->hasParameter($name);
+ }
+}
diff --git a/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ContainerBagInterface.php b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ContainerBagInterface.php
new file mode 100644
index 0000000..1c1227a
--- /dev/null
+++ b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ContainerBagInterface.php
@@ -0,0 +1,57 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\ParameterBag;
+
+use Psr\Container\ContainerInterface;
+use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
+
+/**
+ * ContainerBagInterface is the interface implemented by objects that manage service container parameters.
+ *
+ * @author Nicolas Grekas <p@tchwork.com>
+ */
+interface ContainerBagInterface extends ContainerInterface
+{
+ /**
+ * Gets the service container parameters.
+ *
+ * @return array An array of parameters
+ */
+ public function all();
+
+ /**
+ * Replaces parameter placeholders (%name%) by their values.
+ *
+ * @param mixed $value A value
+ *
+ * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
+ */
+ public function resolveValue($value);
+
+ /**
+ * Escape parameter placeholders %.
+ *
+ * @param mixed $value
+ *
+ * @return mixed
+ */
+ public function escapeValue($value);
+
+ /**
+ * Unescape parameter placeholders %.
+ *
+ * @param mixed $value
+ *
+ * @return mixed
+ */
+ public function unescapeValue($value);
+}
diff --git a/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
new file mode 100644
index 0000000..8724086
--- /dev/null
+++ b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php
@@ -0,0 +1,173 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\ParameterBag;
+
+use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
+use Symfony\Component\DependencyInjection\Exception\RuntimeException;
+
+/**
+ * @author Nicolas Grekas <p@tchwork.com>
+ */
+class EnvPlaceholderParameterBag extends ParameterBag
+{
+ private $envPlaceholderUniquePrefix;
+ private $envPlaceholders = [];
+ private $unusedEnvPlaceholders = [];
+ private $providedTypes = [];
+
+ private static $counter = 0;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get($name)
+ {
+ if (0 === strpos($name, 'env(') && ')' === substr($name, -1) && 'env()' !== $name) {
+ $env = substr($name, 4, -1);
+
+ if (isset($this->envPlaceholders[$env])) {
+ foreach ($this->envPlaceholders[$env] as $placeholder) {
+ return $placeholder; // return first result
+ }
+ }
+ if (isset($this->unusedEnvPlaceholders[$env])) {
+ foreach ($this->unusedEnvPlaceholders[$env] as $placeholder) {
+ return $placeholder; // return first result
+ }
+ }
+ if (!preg_match('/^(?:\w*+:)*+\w++$/', $env)) {
+ throw new InvalidArgumentException(sprintf('Invalid %s name: only "word" characters are allowed.', $name));
+ }
+
+ if ($this->has($name)) {
+ $defaultValue = parent::get($name);
+
+ if (null !== $defaultValue && !is_scalar($defaultValue)) { // !is_string in 5.0
+ //throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name));
+ throw new RuntimeException(sprintf('The default value of an env() parameter must be scalar or null, but "%s" given to "%s".', \gettype($defaultValue), $name));
+ } elseif (is_scalar($defaultValue) && !\is_string($defaultValue)) {
+ @trigger_error(sprintf('A non-string default value of an env() parameter is deprecated since 4.3, cast "%s" to string instead.', $name), E_USER_DEPRECATED);
+ }
+ }
+
+ $uniqueName = md5($name.'_'.self::$counter++);
+ $placeholder = sprintf('%s_%s_%s', $this->getEnvPlaceholderUniquePrefix(), str_replace(':', '_', $env), $uniqueName);
+ $this->envPlaceholders[$env][$placeholder] = $placeholder;
+
+ return $placeholder;
+ }
+
+ return parent::get($name);
+ }
+
+ /**
+ * Gets the common env placeholder prefix for env vars created by this bag.
+ */
+ public function getEnvPlaceholderUniquePrefix(): string
+ {
+ if (null === $this->envPlaceholderUniquePrefix) {
+ $reproducibleEntropy = unserialize(serialize($this->parameters));
+ array_walk_recursive($reproducibleEntropy, function (&$v) { $v = null; });
+ $this->envPlaceholderUniquePrefix = 'env_'.substr(md5(serialize($reproducibleEntropy)), -16);
+ }
+
+ return $this->envPlaceholderUniquePrefix;
+ }
+
+ /**
+ * 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
+ */
+ public function getEnvPlaceholders()
+ {
+ return $this->envPlaceholders;
+ }
+
+ public function getUnusedEnvPlaceholders(): array
+ {
+ return $this->unusedEnvPlaceholders;
+ }
+
+ public function clearUnusedEnvPlaceholders()
+ {
+ $this->unusedEnvPlaceholders = [];
+ }
+
+ /**
+ * Merges the env placeholders of another EnvPlaceholderParameterBag.
+ */
+ public function mergeEnvPlaceholders(self $bag)
+ {
+ if ($newPlaceholders = $bag->getEnvPlaceholders()) {
+ $this->envPlaceholders += $newPlaceholders;
+
+ foreach ($newPlaceholders as $env => $placeholders) {
+ $this->envPlaceholders[$env] += $placeholders;
+ }
+ }
+
+ if ($newUnusedPlaceholders = $bag->getUnusedEnvPlaceholders()) {
+ $this->unusedEnvPlaceholders += $newUnusedPlaceholders;
+
+ foreach ($newUnusedPlaceholders as $env => $placeholders) {
+ $this->unusedEnvPlaceholders[$env] += $placeholders;
+ }
+ }
+ }
+
+ /**
+ * Maps env prefixes to their corresponding PHP types.
+ */
+ public function setProvidedTypes(array $providedTypes)
+ {
+ $this->providedTypes = $providedTypes;
+ }
+
+ /**
+ * Gets the PHP types corresponding to env() parameter prefixes.
+ *
+ * @return string[][]
+ */
+ public function getProvidedTypes()
+ {
+ return $this->providedTypes;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function resolve()
+ {
+ if ($this->resolved) {
+ return;
+ }
+ parent::resolve();
+
+ foreach ($this->envPlaceholders as $env => $placeholders) {
+ if (!$this->has($name = "env($env)")) {
+ continue;
+ }
+ if (is_numeric($default = $this->parameters[$name])) {
+ if (!\is_string($default)) {
+ @trigger_error(sprintf('A non-string default value of env parameter "%s" is deprecated since 4.3, cast it to string instead.', $env), E_USER_DEPRECATED);
+ }
+ $this->parameters[$name] = (string) $default;
+ } elseif (null !== $default && !is_scalar($default)) { // !is_string in 5.0
+ //throw new RuntimeException(sprintf('The default value of env parameter "%s" must be a string or null, %s given.', $env, \gettype($default)));
+ throw new RuntimeException(sprintf('The default value of env parameter "%s" must be scalar or null, %s given.', $env, \gettype($default)));
+ } elseif (is_scalar($default) && !\is_string($default)) {
+ @trigger_error(sprintf('A non-string default value of env parameter "%s" is deprecated since 4.3, cast it to string instead.', $env), E_USER_DEPRECATED);
+ }
+ }
+ }
+}
diff --git a/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php
new file mode 100644
index 0000000..a519993
--- /dev/null
+++ b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/FrozenParameterBag.php
@@ -0,0 +1,68 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\ParameterBag;
+
+use Symfony\Component\DependencyInjection\Exception\LogicException;
+
+/**
+ * Holds read-only parameters.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+class FrozenParameterBag extends ParameterBag
+{
+ /**
+ * For performance reasons, the constructor assumes that
+ * all keys are already lowercased.
+ *
+ * This is always the case when used internally.
+ *
+ * @param array $parameters An array of parameters
+ */
+ public function __construct(array $parameters = [])
+ {
+ $this->parameters = $parameters;
+ $this->resolved = true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function clear()
+ {
+ throw new LogicException('Impossible to call clear() on a frozen ParameterBag.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function add(array $parameters)
+ {
+ throw new LogicException('Impossible to call add() on a frozen ParameterBag.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function set($name, $value)
+ {
+ throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function remove($name)
+ {
+ throw new LogicException('Impossible to call remove() on a frozen ParameterBag.');
+ }
+}
diff --git a/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
new file mode 100644
index 0000000..48887c3
--- /dev/null
+++ b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php
@@ -0,0 +1,289 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\ParameterBag;
+
+use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
+use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
+use Symfony\Component\DependencyInjection\Exception\RuntimeException;
+
+/**
+ * Holds parameters.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+class ParameterBag implements ParameterBagInterface
+{
+ protected $parameters = [];
+ protected $resolved = false;
+
+ /**
+ * @param array $parameters An array of parameters
+ */
+ public function __construct(array $parameters = [])
+ {
+ $this->add($parameters);
+ }
+
+ /**
+ * Clears all parameters.
+ */
+ public function clear()
+ {
+ $this->parameters = [];
+ }
+
+ /**
+ * Adds parameters to the service container parameters.
+ *
+ * @param array $parameters An array of parameters
+ */
+ public function add(array $parameters)
+ {
+ foreach ($parameters as $key => $value) {
+ $this->set($key, $value);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function all()
+ {
+ return $this->parameters;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get($name)
+ {
+ $name = (string) $name;
+
+ if (!\array_key_exists($name, $this->parameters)) {
+ if (!$name) {
+ throw new ParameterNotFoundException($name);
+ }
+
+ $alternatives = [];
+ foreach ($this->parameters as $key => $parameterValue) {
+ $lev = levenshtein($name, $key);
+ if ($lev <= \strlen($name) / 3 || false !== strpos($key, $name)) {
+ $alternatives[] = $key;
+ }
+ }
+
+ $nonNestedAlternative = null;
+ if (!\count($alternatives) && false !== strpos($name, '.')) {
+ $namePartsLength = array_map('strlen', explode('.', $name));
+ $key = substr($name, 0, -1 * (1 + array_pop($namePartsLength)));
+ while (\count($namePartsLength)) {
+ if ($this->has($key)) {
+ if (\is_array($this->get($key))) {
+ $nonNestedAlternative = $key;
+ }
+ break;
+ }
+
+ $key = substr($key, 0, -1 * (1 + array_pop($namePartsLength)));
+ }
+ }
+
+ throw new ParameterNotFoundException($name, null, null, null, $alternatives, $nonNestedAlternative);
+ }
+
+ return $this->parameters[$name];
+ }
+
+ /**
+ * Sets a service container parameter.
+ *
+ * @param string $name The parameter name
+ * @param mixed $value The parameter value
+ */
+ public function set($name, $value)
+ {
+ $this->parameters[(string) $name] = $value;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function has($name)
+ {
+ return \array_key_exists((string) $name, $this->parameters);
+ }
+
+ /**
+ * Removes a parameter.
+ *
+ * @param string $name The parameter name
+ */
+ public function remove($name)
+ {
+ unset($this->parameters[(string) $name]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function resolve()
+ {
+ if ($this->resolved) {
+ return;
+ }
+
+ $parameters = [];
+ foreach ($this->parameters as $key => $value) {
+ try {
+ $value = $this->resolveValue($value);
+ $parameters[$key] = $this->unescapeValue($value);
+ } catch (ParameterNotFoundException $e) {
+ $e->setSourceKey($key);
+
+ throw $e;
+ }
+ }
+
+ $this->parameters = $parameters;
+ $this->resolved = true;
+ }
+
+ /**
+ * Replaces parameter placeholders (%name%) by their values.
+ *
+ * @param mixed $value A value
+ * @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
+ *
+ * @return mixed The resolved value
+ *
+ * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
+ * @throws ParameterCircularReferenceException if a circular reference if detected
+ * @throws RuntimeException when a given parameter has a type problem
+ */
+ public function resolveValue($value, array $resolving = [])
+ {
+ if (\is_array($value)) {
+ $args = [];
+ foreach ($value as $k => $v) {
+ $args[\is_string($k) ? $this->resolveValue($k, $resolving) : $k] = $this->resolveValue($v, $resolving);
+ }
+
+ return $args;
+ }
+
+ if (!\is_string($value) || 2 > \strlen($value)) {
+ return $value;
+ }
+
+ return $this->resolveString($value, $resolving);
+ }
+
+ /**
+ * Resolves parameters inside a string.
+ *
+ * @param string $value The string to resolve
+ * @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
+ *
+ * @return mixed The resolved string
+ *
+ * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
+ * @throws ParameterCircularReferenceException if a circular reference if detected
+ * @throws RuntimeException when a given parameter has a type problem
+ */
+ public function resolveString($value, array $resolving = [])
+ {
+ // we do this to deal with non string values (Boolean, integer, ...)
+ // as the preg_replace_callback throw an exception when trying
+ // a non-string in a parameter value
+ if (preg_match('/^%([^%\s]+)%$/', $value, $match)) {
+ $key = $match[1];
+
+ if (isset($resolving[$key])) {
+ throw new ParameterCircularReferenceException(array_keys($resolving));
+ }
+
+ $resolving[$key] = true;
+
+ return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving);
+ }
+
+ return preg_replace_callback('/%%|%([^%\s]+)%/', function ($match) use ($resolving, $value) {
+ // skip %%
+ if (!isset($match[1])) {
+ return '%%';
+ }
+
+ $key = $match[1];
+ if (isset($resolving[$key])) {
+ throw new ParameterCircularReferenceException(array_keys($resolving));
+ }
+
+ $resolved = $this->get($key);
+
+ if (!\is_string($resolved) && !is_numeric($resolved)) {
+ throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".', $key, \gettype($resolved), $value));
+ }
+
+ $resolved = (string) $resolved;
+ $resolving[$key] = true;
+
+ return $this->isResolved() ? $resolved : $this->resolveString($resolved, $resolving);
+ }, $value);
+ }
+
+ public function isResolved()
+ {
+ return $this->resolved;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function escapeValue($value)
+ {
+ if (\is_string($value)) {
+ return str_replace('%', '%%', $value);
+ }
+
+ if (\is_array($value)) {
+ $result = [];
+ foreach ($value as $k => $v) {
+ $result[$k] = $this->escapeValue($v);
+ }
+
+ return $result;
+ }
+
+ return $value;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function unescapeValue($value)
+ {
+ if (\is_string($value)) {
+ return str_replace('%%', '%', $value);
+ }
+
+ if (\is_array($value)) {
+ $result = [];
+ foreach ($value as $k => $v) {
+ $result[$k] = $this->unescapeValue($v);
+ }
+
+ return $result;
+ }
+
+ return $value;
+ }
+}
diff --git a/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ParameterBagInterface.php b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ParameterBagInterface.php
new file mode 100644
index 0000000..6a4e0fa
--- /dev/null
+++ b/srcs/phpmyadmin/vendor/symfony/dependency-injection/ParameterBag/ParameterBagInterface.php
@@ -0,0 +1,115 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\ParameterBag;
+
+use Symfony\Component\DependencyInjection\Exception\LogicException;
+use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
+
+/**
+ * ParameterBagInterface is the interface implemented by objects that manage service container parameters.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+interface ParameterBagInterface
+{
+ /**
+ * Clears all parameters.
+ *
+ * @throws LogicException if the ParameterBagInterface can not be cleared
+ */
+ public function clear();
+
+ /**
+ * Adds parameters to the service container parameters.
+ *
+ * @param array $parameters An array of parameters
+ *
+ * @throws LogicException if the parameter can not be added
+ */
+ public function add(array $parameters);
+
+ /**
+ * Gets the service container parameters.
+ *
+ * @return array An array of parameters
+ */
+ public function all();
+
+ /**
+ * Gets a service container parameter.
+ *
+ * @param string $name The parameter name
+ *
+ * @return mixed The parameter value
+ *
+ * @throws ParameterNotFoundException if the parameter is not defined
+ */
+ public function get($name);
+
+ /**
+ * Removes a parameter.
+ *
+ * @param string $name The parameter name
+ */
+ public function remove($name);
+
+ /**
+ * Sets a service container parameter.
+ *
+ * @param string $name The parameter name
+ * @param mixed $value The parameter value
+ *
+ * @throws LogicException if the parameter can not be set
+ */
+ public function set($name, $value);
+
+ /**
+ * Returns true if a parameter name is defined.
+ *
+ * @param string $name The parameter name
+ *
+ * @return bool true if the parameter name is defined, false otherwise
+ */
+ public function has($name);
+
+ /**
+ * Replaces parameter placeholders (%name%) by their values for all parameters.
+ */
+ public function resolve();
+
+ /**
+ * Replaces parameter placeholders (%name%) by their values.
+ *
+ * @param mixed $value A value
+ *
+ * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
+ */
+ public function resolveValue($value);
+
+ /**
+ * Escape parameter placeholders %.
+ *
+ * @param mixed $value
+ *
+ * @return mixed
+ */
+ public function escapeValue($value);
+
+ /**
+ * Unescape parameter placeholders %.
+ *
+ * @param mixed $value
+ *
+ * @return mixed
+ */
+ public function unescapeValue($value);
+}