diff vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
line wrap: on
line diff
--- a/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php	Mon Apr 23 09:46:53 2018 +0100
@@ -20,6 +20,7 @@
 class EnvPlaceholderParameterBag extends ParameterBag
 {
     private $envPlaceholders = array();
+    private $providedTypes = array();
 
     /**
      * {@inheritdoc}
@@ -34,7 +35,7 @@
                     return $placeholder; // return first result
                 }
             }
-            if (preg_match('/\W/', $env)) {
+            if (!preg_match('/^(?:\w++:)*+\w++$/', $env)) {
                 throw new InvalidArgumentException(sprintf('Invalid %s name: only "word" characters are allowed.', $name));
             }
 
@@ -47,7 +48,7 @@
             }
 
             $uniqueName = md5($name.uniqid(mt_rand(), true));
-            $placeholder = sprintf('env_%s_%s', $env, $uniqueName);
+            $placeholder = sprintf('env_%s_%s', str_replace(':', '_', $env), $uniqueName);
             $this->envPlaceholders[$env][$placeholder] = $placeholder;
 
             return $placeholder;
@@ -81,6 +82,24 @@
     }
 
     /**
+     * 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()
@@ -91,7 +110,7 @@
         parent::resolve();
 
         foreach ($this->envPlaceholders as $env => $placeholders) {
-            if (!isset($this->parameters[$name = strtolower("env($env)")])) {
+            if (!$this->has($name = "env($env)")) {
                 continue;
             }
             if (is_numeric($default = $this->parameters[$name])) {