Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag::resolve PHP Method

resolve() public method

public resolve ( )
    public function resolve()
    {
        if ($this->resolved) {
            return;
        }
        parent::resolve();
        foreach ($this->envPlaceholders as $env => $placeholders) {
            if (!isset($this->parameters[$name = strtolower("env({$env})")])) {
                continue;
            }
            if (is_numeric($default = $this->parameters[$name])) {
                $this->parameters[$name] = (string) $default;
            } elseif (null !== $default && !is_scalar($default)) {
                throw new RuntimeException(sprintf('The default value of env parameter "%s" must be scalar or null, %s given.', $env, gettype($default)));
            }
        }
    }

Usage Example

 /**
  * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
  * @expectedExceptionMessage The default value of an env() parameter must be scalar or null, but "array" given to "env(ARRAY_VAR)".
  */
 public function testGetThrowsOnBadDefaultValue()
 {
     $bag = new EnvPlaceholderParameterBag();
     $bag->set('env(ARRAY_VAR)', array());
     $bag->get('env(ARRAY_VAR)');
     $bag->resolve();
 }