Skip to content

Commit 1c70c40

Browse files
committed
Merge branch '4.1'
* 4.1: fixed typo [FrameworkBundle] fixed brackets position in method calls Add placeholder support in bootstrap 4 file fields [Form] Improve rendering of `file` field in bootstrap 4 [Form] Fix PHPDoc for FormConfigBuilder $dataClass argument [Security] Update user phpdoc on tokens [WebProfilerBundle] Fixed icon alignment issue using Bootstrap 4.1.2 suppress side effects in 'get' or 'has' methods of NamespacedAttributeBag [HttpFoundation] reset callback on StreamedResponse when setNotModified() is called [HttpFoundation] Fixed phpdoc for get method of HeaderBag fix typo in ContainerBuilder docblock [Form/Profiler] Massively reducing memory footprint of form profiling pages by removing redundant 'form' variable from view variables. [Console] correctly return parameter's default value on "--" [DependencyInjection] add missing test for #27710 [EventDispatcher] Clear orphaned events on TraceableEventDispatcher::reset Fix serialization of abstract items with groups across multiple entities
2 parents 7afe26f + 5c31f6a commit 1c70c40

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

Input/ArgvInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function getParameterOption($values, $default = false, $onlyParams = fals
301301
while (0 < count($tokens)) {
302302
$token = array_shift($tokens);
303303
if ($onlyParams && '--' === $token) {
304-
return false;
304+
return $default;
305305
}
306306

307307
foreach ($values as $value) {

Input/ArrayInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getParameterOption($values, $default = false, $onlyParams = fals
8181

8282
foreach ($this->parameters as $k => $v) {
8383
if ($onlyParams && ('--' === $k || (is_int($k) && '--' === $v))) {
84-
return false;
84+
return $default;
8585
}
8686

8787
if (is_int($k)) {

Tests/Input/ArgvInputTest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,25 +395,26 @@ public function testToString()
395395
/**
396396
* @dataProvider provideGetParameterOptionValues
397397
*/
398-
public function testGetParameterOptionEqualSign($argv, $key, $onlyParams, $expected)
398+
public function testGetParameterOptionEqualSign($argv, $key, $default, $onlyParams, $expected)
399399
{
400400
$input = new ArgvInput($argv);
401-
$this->assertEquals($expected, $input->getParameterOption($key, false, $onlyParams), '->getParameterOption() returns the expected value');
401+
$this->assertEquals($expected, $input->getParameterOption($key, $default, $onlyParams), '->getParameterOption() returns the expected value');
402402
}
403403

404404
public function provideGetParameterOptionValues()
405405
{
406406
return array(
407-
array(array('app/console', 'foo:bar', '-e', 'dev'), '-e', false, 'dev'),
408-
array(array('app/console', 'foo:bar', '--env=dev'), '--env', false, 'dev'),
409-
array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), false, 'dev'),
410-
array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), false, 'dev'),
411-
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), false, '1'),
412-
array(array('app/console', 'foo:bar', '--env=dev', '', '--en=1'), array('--en'), false, '1'),
413-
array(array('app/console', 'foo:bar', '--env', 'val'), '--env', false, 'val'),
414-
array(array('app/console', 'foo:bar', '--env', 'val', '--dummy'), '--env', false, 'val'),
415-
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', false, 'dev'),
416-
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', true, false),
407+
array(array('app/console', 'foo:bar'), '-e', 'default', false, 'default'),
408+
array(array('app/console', 'foo:bar', '-e', 'dev'), '-e', 'default', false, 'dev'),
409+
array(array('app/console', 'foo:bar', '--env=dev'), '--env', 'default', false, 'dev'),
410+
array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), 'default', false, 'dev'),
411+
array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), 'default', false, 'dev'),
412+
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), 'default', false, '1'),
413+
array(array('app/console', 'foo:bar', '--env=dev', '', '--en=1'), array('--en'), 'default', false, '1'),
414+
array(array('app/console', 'foo:bar', '--env', 'val'), '--env', 'default', false, 'val'),
415+
array(array('app/console', 'foo:bar', '--env', 'val', '--dummy'), '--env', 'default', false, 'val'),
416+
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', 'default', false, 'dev'),
417+
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', 'default', true, 'default'),
417418
);
418419
}
419420

Tests/Input/ArrayInputTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public function testGetParameterOption()
4747
{
4848
$input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
4949
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
50-
$this->assertFalse($input->getParameterOption('--bar'), '->getParameterOption() returns the default if an option is not present in the passed parameters');
50+
$this->assertEquals('default', $input->getParameterOption('--bar', 'default'), '->getParameterOption() returns the default value if an option is not present in the passed parameters');
5151

5252
$input = new ArrayInput(array('Fabien', '--foo' => 'bar'));
5353
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
5454

5555
$input = new ArrayInput(array('--foo', '--', '--bar' => 'woop'));
5656
$this->assertEquals('woop', $input->getParameterOption('--bar'), '->getParameterOption() returns the correct value if an option is present in the passed parameters');
57-
$this->assertFalse($input->getParameterOption('--bar', false, true), '->getParameterOption() returns false if an option is present in the passed parameters after an end of options signal');
57+
$this->assertEquals('default', $input->getParameterOption('--bar', 'default', true), '->getParameterOption() returns the default value if an option is present in the passed parameters after an end of options signal');
5858
}
5959

6060
public function testParseArguments()

0 commit comments

Comments
 (0)