comparison vendor/symfony/dependency-injection/EnvVarProcessor.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
30 /** 30 /**
31 * {@inheritdoc} 31 * {@inheritdoc}
32 */ 32 */
33 public static function getProvidedTypes() 33 public static function getProvidedTypes()
34 { 34 {
35 return array( 35 return [
36 'base64' => 'string', 36 'base64' => 'string',
37 'bool' => 'bool', 37 'bool' => 'bool',
38 'const' => 'bool|int|float|string|array', 38 'const' => 'bool|int|float|string|array',
39 'file' => 'string', 39 'file' => 'string',
40 'float' => 'float', 40 'float' => 'float',
41 'int' => 'int', 41 'int' => 'int',
42 'json' => 'array', 42 'json' => 'array',
43 'resolve' => 'string', 43 'resolve' => 'string',
44 'string' => 'string', 44 'string' => 'string',
45 ); 45 ];
46 } 46 }
47 47
48 /** 48 /**
49 * {@inheritdoc} 49 * {@inheritdoc}
50 */ 50 */
108 108
109 return (float) $env; 109 return (float) $env;
110 } 110 }
111 111
112 if ('const' === $prefix) { 112 if ('const' === $prefix) {
113 if (!defined($env)) { 113 if (!\defined($env)) {
114 throw new RuntimeException(sprintf('Env var "%s" maps to undefined constant "%s".', $name, $env)); 114 throw new RuntimeException(sprintf('Env var "%s" maps to undefined constant "%s".', $name, $env));
115 } 115 }
116 116
117 return constant($env); 117 return \constant($env);
118 } 118 }
119 119
120 if ('base64' === $prefix) { 120 if ('base64' === $prefix) {
121 return base64_decode($env); 121 return base64_decode($env);
122 } 122 }
126 126
127 if (JSON_ERROR_NONE !== json_last_error()) { 127 if (JSON_ERROR_NONE !== json_last_error()) {
128 throw new RuntimeException(sprintf('Invalid JSON in env var "%s": '.json_last_error_msg(), $name)); 128 throw new RuntimeException(sprintf('Invalid JSON in env var "%s": '.json_last_error_msg(), $name));
129 } 129 }
130 130
131 if (!is_array($env)) { 131 if (!\is_array($env)) {
132 throw new RuntimeException(sprintf('Invalid JSON env var "%s": array expected, %s given.', $name, gettype($env))); 132 throw new RuntimeException(sprintf('Invalid JSON env var "%s": array expected, %s given.', $name, \gettype($env)));
133 } 133 }
134 134
135 return $env; 135 return $env;
136 } 136 }
137 137
140 if (!isset($match[1])) { 140 if (!isset($match[1])) {
141 return '%'; 141 return '%';
142 } 142 }
143 $value = $this->container->getParameter($match[1]); 143 $value = $this->container->getParameter($match[1]);
144 if (!is_scalar($value)) { 144 if (!is_scalar($value)) {
145 throw new RuntimeException(sprintf('Parameter "%s" found when resolving env var "%s" must be scalar, "%s" given.', $match[1], $name, gettype($value))); 145 throw new RuntimeException(sprintf('Parameter "%s" found when resolving env var "%s" must be scalar, "%s" given.', $match[1], $name, \gettype($value)));
146 } 146 }
147 147
148 return $value; 148 return $value;
149 }, $env); 149 }, $env);
150 } 150 }