From f96e0e033b4098ce992d5c72eb0bb94ebc282f06 Mon Sep 17 00:00:00 2001 From: Gawain Lynch Date: Mon, 6 Nov 2017 16:30:43 +0100 Subject: [PATCH] Use Terminal class for dimensions post Symfony 3.2 --- src/Composer/Command/ShowCommand.php | 37 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index e850b96d6..694e23874 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -12,32 +12,33 @@ namespace Composer\Command; -use Composer\DependencyResolver\Pool; +use Composer\Composer; use Composer\DependencyResolver\DefaultPolicy; +use Composer\DependencyResolver\Pool; use Composer\Json\JsonFile; -use Composer\Package\CompletePackageInterface; -use Composer\Package\Version\VersionParser; use Composer\Package\BasePackage; +use Composer\Package\CompletePackageInterface; +use Composer\Package\PackageInterface; +use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionSelector; use Composer\Plugin\CommandEvent; use Composer\Plugin\PluginEvents; -use Composer\Package\PackageInterface; +use Composer\Repository\ArrayRepository; +use Composer\Repository\ComposerRepository; +use Composer\Repository\CompositeRepository; +use Composer\Repository\PlatformRepository; +use Composer\Repository\RepositoryFactory; +use Composer\Repository\RepositoryInterface; use Composer\Semver\Constraint\ConstraintInterface; +use Composer\Semver\Semver; +use Composer\Spdx\SpdxLicenses; use Composer\Util\Platform; use Symfony\Component\Console\Formatter\OutputFormatterStyle; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Composer\Repository\ArrayRepository; -use Composer\Repository\CompositeRepository; -use Composer\Repository\ComposerRepository; -use Composer\Repository\PlatformRepository; -use Composer\Repository\RepositoryInterface; -use Composer\Repository\RepositoryFactory; -use Composer\Spdx\SpdxLicenses; -use Composer\Composer; -use Composer\Semver\Semver; +use Symfony\Component\Console\Terminal; /** * @author Robert Schönthal @@ -255,7 +256,13 @@ EOT $packageListFilter = $this->getRootRequires(); } - list($width) = $this->getApplication()->getTerminalDimensions(); + if (class_exists('Symfony\Component\Console\Terminal')) { + $terminal = new Terminal(); + $width = $terminal->getWidth(); + } else { + // For versions of Symfony console before 3.2 + list($width) = $this->getApplication()->getTerminalDimensions(); + } if (null === $width) { // In case the width is not detected, we're probably running the command // outside of a real terminal, use space without a limit