Skip to content

Commit 86b7728

Browse files
author
symfonyaml
committed
[Console] Better error handling when misuse of ArgvInput with arrays
1 parent 1f386a3 commit 86b7728

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function __construct(?array $argv = null, ?InputDefinition $definition =
4747
{
4848
$argv = $argv ?? $_SERVER['argv'] ?? [];
4949

50+
if (array_filter($argv, 'is_array')) {
51+
throw new RuntimeException('Argument values expected to be all scalars, got array.');
52+
}
53+
5054
// strip the application name
5155
array_shift($argv);
5256

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ public static function provideInvalidInput()
327327
new InputDefinition([new InputArgument('name', InputArgument::REQUIRED)]),
328328
'Too many arguments, expected arguments "name".',
329329
],
330+
[
331+
['cli.php', ['array']],
332+
new InputDefinition(),
333+
'Argument values expected to be all scalars, got array.',
334+
],
330335
];
331336
}
332337

0 commit comments

Comments
 (0)