From 36da81bec2b94370aa52d5302961fdf1190a9d97 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 4 Jan 2022 10:41:33 +0100 Subject: [PATCH] Remove obsolete Symfony feature detections (#10425) --- src/Composer/IO/ConsoleIO.php | 6 +++--- src/Composer/Util/ProcessExecutor.php | 15 ++------------- .../Archiver/ArchivableFilesFinderTest.php | 7 +------ .../Question/StrictConfirmationQuestionTest.php | 10 ++-------- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/Composer/IO/ConsoleIO.php b/src/Composer/IO/ConsoleIO.php index 9c8b467fe..63337ec93 100644 --- a/src/Composer/IO/ConsoleIO.php +++ b/src/Composer/IO/ConsoleIO.php @@ -97,7 +97,7 @@ class ConsoleIO extends BaseIO */ public function isVerbose() { - return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE; + return $this->output->isVerbose(); } /** @@ -105,7 +105,7 @@ class ConsoleIO extends BaseIO */ public function isVeryVerbose() { - return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE; + return $this->output->isVeryVerbose(); } /** @@ -113,7 +113,7 @@ class ConsoleIO extends BaseIO */ public function isDebug() { - return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG; + return $this->output->isDebug(); } /** diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index 8c1a3c233..804aee79e 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -118,13 +118,7 @@ class ProcessExecutor $this->captureOutput = func_num_args() > 3; $this->errorOutput = ''; - // TODO in v3, commands should be passed in as arrays of cmd + args - if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) { - $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout()); - } else { - /** @phpstan-ignore-next-line */ - $process = new Process($command, $cwd, null, null, static::getTimeout()); - } + $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout()); if (!Platform::isWindows() && $tty) { try { $process->setTty(true); @@ -249,12 +243,7 @@ class ProcessExecutor } try { - // TODO in v3, commands should be passed in as arrays of cmd + args - if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) { - $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout()); - } else { - $process = new Process($command, $cwd, null, null, static::getTimeout()); - } + $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout()); } catch (\Throwable $e) { call_user_func($job['reject'], $e); diff --git a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php index ca77abb31..883dd4278 100644 --- a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php @@ -281,12 +281,7 @@ class ArchivableFilesFinderTest extends TestCase */ protected function getArchivedFiles($command) { - if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) { - $process = Process::fromShellCommandline($command, $this->sources); - } else { - // @phpstan-ignore-next-line symfony/process 2.8 accepts a string but not 5.3 which is used only for PHPStan - $process = new Process($command, $this->sources); - } + $process = Process::fromShellCommandline($command, $this->sources); $process->run(); $archive = new \PharData($this->sources.'/archive.zip'); diff --git a/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php b/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php index 90fbb4a86..6d82d4ab8 100644 --- a/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php +++ b/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php @@ -134,16 +134,10 @@ class StrictConfirmationQuestionTest extends TestCase */ protected function createInput($entry) { - $stream = $this->getInputStream($entry); $input = new ArrayInput(array('--no-interaction')); - $dialog = new QuestionHelper(); + $input->setStream($this->getInputStream($entry)); - if (method_exists($dialog, 'setInputStream')) { - $dialog->setInputStream($stream); - } - if ($input instanceof StreamableInputInterface) { - $input->setStream($stream); - } + $dialog = new QuestionHelper(); return array($input, $dialog); }