From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Fri, 21 Jun 2024 11:34:16 +0200
Subject: Adapt test before calling fromShellCommandline

Use the test as initially implemented in the 2.2 branch.

Origin: backport, https://github.com/composer/composer/commit/5e4a8a882dc70398c3c53e7b3aabd16790c9e198
Bug-Debian: https://bugs.debian.org/1073931
---
 src/Composer/Util/Perforce.php                                     | 3 +--
 src/Composer/Util/ProcessExecutor.php                              | 6 ++----
 tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php | 2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/Composer/Util/Perforce.php b/src/Composer/Util/Perforce.php
index d399e4c..8edb6ff 100644
--- a/src/Composer/Util/Perforce.php
+++ b/src/Composer/Util/Perforce.php
@@ -369,8 +369,7 @@ class Perforce
     {
         $command = $this->generateP4Command(' login -a');
 
-        // TODO in v3 generate command as an array
-        if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
+        if (is_string($command)) {
             $process = Process::fromShellCommandline($command, null, null, $password);
         } else {
             $process = new Process($command, null, null, $password);
diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php
index f940f49..8728106 100644
--- a/src/Composer/Util/ProcessExecutor.php
+++ b/src/Composer/Util/ProcessExecutor.php
@@ -107,8 +107,7 @@ class ProcessExecutor
         $this->captureOutput = func_num_args() > 3;
         $this->errorOutput = null;
 
-        // TODO in v3, commands should be passed in as arrays of cmd + args
-        if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
+        if (is_string($command)) {
             $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
         } else {
             $process = new Process($command, $cwd, null, null, static::getTimeout());
@@ -239,8 +238,7 @@ class ProcessExecutor
             $cwd = realpath(getcwd());
         }
 
-        // TODO in v3, commands should be passed in as arrays of cmd + args
-        if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
+        if (is_string($command)) {
             $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
         } else {
             $process = new Process($command, $cwd, null, null, static::getTimeout());
diff --git a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php
index 969469b..65226d5 100644
--- a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php
+++ b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php
@@ -309,7 +309,7 @@ class ArchivableFilesFinderTest extends TestCase
 
     protected function getArchivedFiles($command)
     {
-        if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
+        if (is_string($command)) {
             $process = Process::fromShellCommandline($command, $this->sources);
         } else {
             $process = new Process($command, $this->sources);
