Skip to content

Commit

Permalink
Merge branch '4.4' into 5.2
Browse files Browse the repository at this point in the history
* 4.4:
  skip intl dependent tests if the extension is missing
  make DateCaster tests timezone-agnostic
  error if the input string couldn't be parsed as a date
  IntegerType: Always use en for IntegerToLocalizedStringTransformer Fixes #40456
  Uses the correct assignment action for console options depending if they are short or long
  [HttpKernel] ConfigDataCollector to return known data without the need of a Kernel
  [HttpClient] fix using stream_copy_to_stream() with responses cast to php streams
  FIx Trying to clone an uncloneable object of class
  • Loading branch information
xabbuh committed Mar 28, 2021
2 parents 054f548 + 1ba4560 commit 35f039d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Input/ArrayInput.php
Expand Up @@ -108,12 +108,13 @@ public function __toString()
$params = [];
foreach ($this->parameters as $param => $val) {
if ($param && \is_string($param) && '-' === $param[0]) {
$glue = ('-' === $param[1]) ? '=' : ' ';
if (\is_array($val)) {
foreach ($val as $v) {
$params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
$params[] = $param.('' != $v ? $glue.$this->escapeToken($v) : '');
}
} else {
$params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
$params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : '');
}
} else {
$params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val);
Expand Down
4 changes: 2 additions & 2 deletions Tests/Input/ArrayInputTest.php
Expand Up @@ -162,10 +162,10 @@ public function provideInvalidInput()
public function testToString()
{
$input = new ArrayInput(['-f' => null, '-b' => 'bar', '--foo' => 'b a z', '--lala' => null, 'test' => 'Foo', 'test2' => "A\nB'C"]);
$this->assertEquals('-f -b=bar --foo='.escapeshellarg('b a z').' --lala Foo '.escapeshellarg("A\nB'C"), (string) $input);
$this->assertEquals('-f -b bar --foo='.escapeshellarg('b a z').' --lala Foo '.escapeshellarg("A\nB'C"), (string) $input);

$input = new ArrayInput(['-b' => ['bval_1', 'bval_2'], '--f' => ['fval_1', 'fval_2']]);
$this->assertSame('-b=bval_1 -b=bval_2 --f=fval_1 --f=fval_2', (string) $input);
$this->assertSame('-b bval_1 -b bval_2 --f=fval_1 --f=fval_2', (string) $input);

$input = new ArrayInput(['array_arg' => ['val_1', 'val_2']]);
$this->assertSame('val_1 val_2', (string) $input);
Expand Down

0 comments on commit 35f039d

Please sign in to comment.