Closed
Description
Symfony version(s) affected: 4.1.4
Description
If you create a process with an array command-line containing null variable, it will fail:
Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\Process\Process::escapeArgument() must be of the type string, null given in /code/vendor/symfony/process/Process.php:1533
Stack trace:
#0 [internal function]: Symfony\Component\Process\Process->escapeArgument(NULL)
#1 /code/vendor/symfony/process/Process.php(262): array_map(Array, Array)
#2 /code/vendor/symfony/process/Process.php(200): Symfony\Component\Process\Process->start(NULL, Array)
#3 /code/test.php(13): Symfony\Component\Process\Process->run()
#4 {main}
How to reproduce
<?php
declare(strict_types=1);
require_once __DIR__.'/src/autoload.php';
$process = new \Symfony\Component\Process\Process([
'ls -la',
'test',
null,
'something',
]);
$process->run();
Possible Solution
I know it's a new major, but I found nothing about this issue on the upgrade guide. Plus, the error is not very explicit.
Two possibility:
- Cast all null parameter to string before using
escapeArgument
to have the same behavior as Symfony 3. - Complete the upgrade guide and prevent the error by a more explicit one.