comparison vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.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
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
9 * file that was distributed with this source code. 9 * file that was distributed with this source code.
10 */ 10 */
11 11
12 namespace Symfony\Component\DependencyInjection\ParameterBag; 12 namespace Symfony\Component\DependencyInjection\ParameterBag;
13 13
14 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
14 use Symfony\Component\DependencyInjection\Exception\RuntimeException; 15 use Symfony\Component\DependencyInjection\Exception\RuntimeException;
15 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
16 16
17 /** 17 /**
18 * @author Nicolas Grekas <p@tchwork.com> 18 * @author Nicolas Grekas <p@tchwork.com>
19 */ 19 */
20 class EnvPlaceholderParameterBag extends ParameterBag 20 class EnvPlaceholderParameterBag extends ParameterBag
21 { 21 {
22 private $envPlaceholders = array(); 22 private $envPlaceholders = [];
23 private $providedTypes = array(); 23 private $providedTypes = [];
24 24
25 /** 25 /**
26 * {@inheritdoc} 26 * {@inheritdoc}
27 */ 27 */
28 public function get($name) 28 public function get($name)
41 41
42 if ($this->has($name)) { 42 if ($this->has($name)) {
43 $defaultValue = parent::get($name); 43 $defaultValue = parent::get($name);
44 44
45 if (null !== $defaultValue && !is_scalar($defaultValue)) { 45 if (null !== $defaultValue && !is_scalar($defaultValue)) {
46 throw new RuntimeException(sprintf('The default value of an env() parameter must be scalar or null, but "%s" given to "%s".', gettype($defaultValue), $name)); 46 throw new RuntimeException(sprintf('The default value of an env() parameter must be scalar or null, but "%s" given to "%s".', \gettype($defaultValue), $name));
47 } 47 }
48 } 48 }
49 49
50 $uniqueName = md5($name.uniqid(mt_rand(), true)); 50 $uniqueName = md5($name.uniqid(mt_rand(), true));
51 $placeholder = sprintf('env_%s_%s', str_replace(':', '_', $env), $uniqueName); 51 $placeholder = sprintf('env_%s_%s', str_replace(':', '_', $env), $uniqueName);
114 continue; 114 continue;
115 } 115 }
116 if (is_numeric($default = $this->parameters[$name])) { 116 if (is_numeric($default = $this->parameters[$name])) {
117 $this->parameters[$name] = (string) $default; 117 $this->parameters[$name] = (string) $default;
118 } elseif (null !== $default && !is_scalar($default)) { 118 } elseif (null !== $default && !is_scalar($default)) {
119 throw new RuntimeException(sprintf('The default value of env parameter "%s" must be scalar or null, %s given.', $env, gettype($default))); 119 throw new RuntimeException(sprintf('The default value of env parameter "%s" must be scalar or null, %s given.', $env, \gettype($default)));
120 } 120 }
121 } 121 }
122 } 122 }
123 } 123 }