10BC0 [DI] Updated return types of key env var resolver · symfony/symfony@d2ec983 · GitHub
[go: up one dir, main page]

Skip to content

Commit d2ec983

Browse files
[DI] Updated return types of key env var resolver
1 parent 8d311e8 commit d2ec983

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/Symfony/Component/DependencyInjection/EnvVarProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function getProvidedTypes()
4141
'float' => 'float',
4242
'int' => 'int',
4343
'json' => 'array',
44-
'key' => 'string',
44+
'key' => 'bool|int|float|string|array',
4545
'resolve' => 'string',
4646
'string' => 'string',
4747
);

src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testSimpleProcessor()
3838
'float' => array('float'),
3939
'int' => array('int'),
4040
'json' => array('array'),
41-
'key' => array('string'),
41+
'key' => array('bool', 'int', 'float', 'string', 'array'),
4242
'resolve' => array('string'),
4343
'string' => array('string'),
4444
);

src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,19 +379,35 @@ public function invalidArrayValues()
379379
);
380380
}
381381

382-
public function testGetEnvKey()
382+
/**
383+
* @dataProvider arrayValues
384+
*/
385+
public function testGetEnvKey($value)
383386
{
384387
$processor = new EnvVarProcessor(new Container());
385388

386-
$this->assertSame('password', $processor->getEnv('key', 'index:foo', function ($name) {
389+
$this->assertSame($value['index'], $processor->getEnv('key', 'index:foo', function ($name) use ($value) {
387390
$this->assertSame('foo', $name);
388391

389-
return array(
390-
'index' => 'password',
391-
);
392+
return $value;
392393
}));
393394
}
394395

396+
public function arrayValues()
397+
{
398+
return array(
399+
array(array('index' => 'password')),
400+
array(array('index' => 'true')),
401+
array(array('index' => false)),
402+
array(array('index' => '1')),
403+
array(array('index' => 1)),
404+
array(array('index' => '1.1')),
405+
array(array('index' => 1.1)),
406+
array(array('index' => array())),
407+
array(array('index' => array('val1', 'val2'))),
408+
);
409+
}
410+
395411
public function testGetEnvKeyChained()
396412
{
397413
$processor = new EnvVarProcessor(new Container());

0 commit comments

Comments
 (0)
0