16
16
final class CommandExecutor
17
17
{
18
18
/**
19
- * @var string
19
+ * @var string|array
20
20
*/
21
21
private $ command ;
22
22
@@ -31,8 +31,8 @@ final class CommandExecutor
31
31
private $ result ;
32
32
33
33
/**
34
- * @param string $command
35
- * @param string $cwd
34
+ * @param string|array $command
35
+ * @param string $cwd
36
36
*/
37
37
public function __construct ($ command , $ cwd )
38
38
{
@@ -41,8 +41,8 @@ public function __construct($command, $cwd)
41
41
}
42
42
43
43
/**
44
- * @param string $command
45
- * @param string $cwd
44
+ * @param string|array $command
45
+ * @param string $cwd
46
46
*
47
47
* @return self
48
48
*/
@@ -61,8 +61,7 @@ public static function create($command, $cwd)
61
61
public function getResult ($ checkCode = true )
62
62
{
63
63
if (null === $ this ->result ) {
64
- // for symfony/process:^4.2
65
- if (method_exists (Process::class, 'fromShellCommandline ' )) {
64
+ if (\is_string ($ this ->command ) && method_exists (Process::class, 'fromShellCommandline ' )) {
66
65
$ process = Process::fromShellCommandline ($ this ->command , $ this ->cwd );
67
66
} else {
68
67
$ process = new Process ($ this ->command , $ this ->cwd );
@@ -81,7 +80,7 @@ public function getResult($checkCode = true)
81
80
$ this ->result ,
82
81
sprintf (
83
82
"Cannot execute `%s`: \nCode: %s \nExit text: %s \nError output: %s \nDetails: \n%s " ,
84
- $ this -> command ,
83
+ $ process -> getCommandLine () ,
85
84
$ this ->result ->getCode (),
86
85
isset (Process::$ exitCodes [$ this ->result ->getCode ()]) ? Process::$ exitCodes [$ this ->result ->getCode ()] : 'Unknown exit code ' ,
87
86
$ this ->result ->getError (),
0 commit comments