Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children | af1871eacc83 |
line wrap: on
line diff
--- a/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php Tue Jul 10 15:07:59 2018 +0100 +++ b/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php Thu Feb 28 13:21:36 2019 +0000 @@ -11,8 +11,8 @@ namespace Symfony\Component\DependencyInjection\ParameterBag; +use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException; use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; -use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; /** @@ -22,15 +22,15 @@ */ class ParameterBag implements ParameterBagInterface { - protected $parameters = array(); + protected $parameters = []; protected $resolved = false; - private $normalizedNames = array(); + private $normalizedNames = []; /** * @param array $parameters An array of parameters */ - public function __construct(array $parameters = array()) + public function __construct(array $parameters = []) { $this->add($parameters); } @@ -40,7 +40,7 @@ */ public function clear() { - $this->parameters = array(); + $this->parameters = []; } /** @@ -75,21 +75,21 @@ throw new ParameterNotFoundException($name); } - $alternatives = array(); + $alternatives = []; foreach ($this->parameters as $key => $parameterValue) { $lev = levenshtein($name, $key); - if ($lev <= strlen($name) / 3 || false !== strpos($key, $name)) { + if ($lev <= \strlen($name) / 3 || false !== strpos($key, $name)) { $alternatives[] = $key; } } $nonNestedAlternative = null; - if (!count($alternatives) && false !== strpos($name, '.')) { + if (!\count($alternatives) && false !== strpos($name, '.')) { $namePartsLength = array_map('strlen', explode('.', $name)); $key = substr($name, 0, -1 * (1 + array_pop($namePartsLength))); - while (count($namePartsLength)) { + while (\count($namePartsLength)) { if ($this->has($key)) { - if (is_array($this->get($key))) { + if (\is_array($this->get($key))) { $nonNestedAlternative = $key; } break; @@ -143,7 +143,7 @@ return; } - $parameters = array(); + $parameters = []; foreach ($this->parameters as $key => $value) { try { $value = $this->resolveValue($value); @@ -171,10 +171,10 @@ * @throws ParameterCircularReferenceException if a circular reference if detected * @throws RuntimeException when a given parameter has a type problem */ - public function resolveValue($value, array $resolving = array()) + public function resolveValue($value, array $resolving = []) { if (\is_array($value)) { - $args = array(); + $args = []; foreach ($value as $k => $v) { $args[\is_string($k) ? $this->resolveValue($k, $resolving) : $k] = $this->resolveValue($v, $resolving); } @@ -201,7 +201,7 @@ * @throws ParameterCircularReferenceException if a circular reference if detected * @throws RuntimeException when a given parameter has a type problem */ - public function resolveString($value, array $resolving = array()) + 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 @@ -233,8 +233,8 @@ $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)); + 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; @@ -254,12 +254,12 @@ */ public function escapeValue($value) { - if (is_string($value)) { + if (\is_string($value)) { return str_replace('%', '%%', $value); } - if (is_array($value)) { - $result = array(); + if (\is_array($value)) { + $result = []; foreach ($value as $k => $v) { $result[$k] = $this->escapeValue($v); } @@ -275,12 +275,12 @@ */ public function unescapeValue($value) { - if (is_string($value)) { + if (\is_string($value)) { return str_replace('%%', '%', $value); } - if (is_array($value)) { - $result = array(); + if (\is_array($value)) { + $result = []; foreach ($value as $k => $v) { $result[$k] = $this->unescapeValue($v); }