Description
Symfony version(s) affected: >=2.3
Description
According to Symfonys documentation page [1] and to the docopt [2] definition, a short option (Options defined with one -
) should be followed immediately by the value, or by an optional space. For example: -fFILE
or -f FILE
.
In the class Symfony\Component\Console\Input\ArrayInput
, the method __toString()
, formats an input like ['-f' => 'file']
as -f=file
, which is not expected (Expected -f file
or -ffile
).
How to reproduce
$args = [
'-f' => 'file',
'foo' => 'bar',
];
$input = new ArrayInput($args);
$this->assertEquals('-f file bar', $input->__toString());
Failed asserting that two strings are equal.
Expected :'-f file bar'
Actual :'-f=file bar'
Possible Solution
Fix the __toString()
method to take into consideration -
vs --
when assigning with =
. The last commit introduced the issue, as it was previously working as expected. It can be seen in the tests on commit: https://github.com/symfony/symfony/blame/659eb663c69e0ef989ada10b0dd36b1c05c78c2c/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php
I'm working on a PR.