From ce521e5697ee479308557ed78da03bc7596c68dc Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 6 Mar 2018 12:57:44 +0100 Subject: [PATCH 1/4] Take only displayed packages into account to determine column width The ShowCommand was taking all packages into account when determining the max lengths used to display the width of each column. This was causing unnecessary hiding of columns in case of using a longer name or a longer version in a different package. This was especially visible when using the outdated command, as it applies filtering by default. --- src/Composer/Command/ShowCommand.php | 36 +++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index ae2307e5c..4392e9ef2 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -329,23 +329,17 @@ EOT ksort($packages[$type]); $nameLength = $versionLength = $latestLength = 0; - foreach ($packages[$type] as $package) { - if (is_object($package)) { - $nameLength = max($nameLength, strlen($package->getPrettyName())); - if ($showVersion) { - $versionLength = max($versionLength, strlen($package->getFullPrettyVersion())); - if ($showLatest) { - $latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly); - if ($latestPackage === false) { - continue; - } - $latestPackages[$package->getPrettyName()] = $latestPackage; - $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion())); + if ($showLatest && $showVersion) { + foreach ($packages[$type] as $package) { + if (is_object($package)) { + $latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly); + if ($latestPackage === false) { + continue; } + + $latestPackages[$package->getPrettyName()] = $latestPackage; } - } else { - $nameLength = max($nameLength, strlen($package)); } } @@ -357,11 +351,6 @@ EOT $hasOutdatedPackages = false; $viewData[$type] = array(); - $viewMetaData[$type] = array( - 'nameLength' => $nameLength, - 'versionLength' => $versionLength, - 'latestLength' => $latestLength, - ); foreach ($packages[$type] as $package) { $packageViewData = array(); if (is_object($package)) { @@ -376,12 +365,15 @@ EOT } $packageViewData['name'] = $package->getPrettyName(); + $nameLength = max($nameLength, strlen($package->getPrettyName())); if ($writeVersion) { $packageViewData['version'] = $package->getFullPrettyVersion(); + $versionLength = max($versionLength, strlen($package->getFullPrettyVersion())); } if ($writeLatest && $latestPackage) { $packageViewData['latest'] = $latestPackage->getFullPrettyVersion(); $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package); + $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion())); } if ($writeDescription) { $packageViewData['description'] = $package->getDescription(); @@ -403,9 +395,15 @@ EOT } } else { $packageViewData['name'] = $package; + $nameLength = max($nameLength, strlen($package)); } $viewData[$type][] = $packageViewData; } + $viewMetaData[$type] = array( + 'nameLength' => $nameLength, + 'versionLength' => $versionLength, + 'latestLength' => $latestLength, + ); if ($input->getOption('strict') && $hasOutdatedPackages) { $exitCode = 1; break; From 9dc62222889e310ba20a7aa1c4f4b9fc9434d6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20Rodr=C3=ADguez?= Date: Wed, 21 Feb 2018 00:49:11 -0300 Subject: [PATCH 2/4] Allow using fossil dependency in a fossil repository, fixes #7125, closes #7126 --- src/Composer/Downloader/FossilDownloader.php | 2 +- src/Composer/Repository/Vcs/FossilDriver.php | 2 +- tests/Composer/Test/Downloader/FossilDownloaderTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Downloader/FossilDownloader.php b/src/Composer/Downloader/FossilDownloader.php index 6dd4c0c42..135e973e0 100644 --- a/src/Composer/Downloader/FossilDownloader.php +++ b/src/Composer/Downloader/FossilDownloader.php @@ -36,7 +36,7 @@ class FossilDownloader extends VcsDownloader if (0 !== $this->process->execute($command, $ignoredOutput)) { throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); } - $command = sprintf('fossil open %s', ProcessExecutor::escape($repoFile)); + $command = sprintf('fossil open %s --nested', ProcessExecutor::escape($repoFile)); if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) { throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); } diff --git a/src/Composer/Repository/Vcs/FossilDriver.php b/src/Composer/Repository/Vcs/FossilDriver.php index 7af97ad3e..0b689e7bf 100644 --- a/src/Composer/Repository/Vcs/FossilDriver.php +++ b/src/Composer/Repository/Vcs/FossilDriver.php @@ -96,7 +96,7 @@ class FossilDriver extends VcsDriver throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output); } - if (0 !== $this->process->execute(sprintf('fossil open %s', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) { + if (0 !== $this->process->execute(sprintf('fossil open %s --nested', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) { $output = $this->process->getErrorOutput(); throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output); diff --git a/tests/Composer/Test/Downloader/FossilDownloaderTest.php b/tests/Composer/Test/Downloader/FossilDownloaderTest.php index 2e1de934d..961686bef 100644 --- a/tests/Composer/Test/Downloader/FossilDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FossilDownloaderTest.php @@ -76,7 +76,7 @@ class FossilDownloaderTest extends TestCase ->with($this->equalTo($expectedFossilCommand)) ->will($this->returnValue(0)); - $expectedFossilCommand = $this->getCmd('fossil open \'repo.fossil\''); + $expectedFossilCommand = $this->getCmd('fossil open \'repo.fossil\' --nested'); $processExecutor->expects($this->at(1)) ->method('execute') ->with($this->equalTo($expectedFossilCommand)) From f0a1eaaabfe23a5fdbc7664d39b17d183d53ee9f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 13 Apr 2018 09:49:07 +0200 Subject: [PATCH 3/4] Clarify that inline aliases are root only, fixes #7217 --- doc/articles/aliases.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/articles/aliases.md b/doc/articles/aliases.md index bda6f79a8..49261b22a 100644 --- a/doc/articles/aliases.md +++ b/doc/articles/aliases.md @@ -92,13 +92,14 @@ Just add this to your project's root `composer.json`: That will fetch the `dev-bugfix` version of `monolog/monolog` from your GitHub and alias it to `1.0.x-dev`. -> **Note:** If a package with inline aliases is required, the alias (right of -> the `as`) is used as the version constraint. The part left of the `as` is -> discarded. As a consequence, if A requires B and B requires `monolog/monolog` -> version `dev-bugfix as 1.0.x-dev`, installing A will make B require -> `1.0.x-dev`, which may exist as a branch alias or an actual `1.0` branch. If -> it does not, it must be re-inline-aliased in A's `composer.json`. +> **Note:** Inline aliasing is a root-only feature. If a package with inline +> aliases is required, the alias (right of the `as`) is used as the version +> constraint. The part left of the `as` is discarded. As a consequence, if +> A requires B and B requires `monolog/monolog` version `dev-bugfix as 1.0.x-dev`, +> installing A will make B require `1.0.x-dev`, which may exist as a branch +> alias or an actual `1.0` branch. If it does not, it must be +> inline-aliased again in A's `composer.json`. > **Note:** Inline aliasing should be avoided, especially for published -> packages. If you found a bug, try and get your fix merged upstream. This -> helps to avoid issues for users of your package. +> packages/libraries. If you found a bug, try and get your fix merged upstream. +> This helps to avoid issues for users of your package. From e37e7f1329af4c205439d49dc1297c46f6648ccb Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 13 Apr 2018 10:43:39 +0200 Subject: [PATCH 4/4] Fix handling of non-callable event listeners, fixes #7229 --- src/Composer/EventDispatcher/EventDispatcher.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 2a180614c..7f7a2cd86 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -166,7 +166,12 @@ class EventDispatcher $return = 0; foreach ($listeners as $callable) { - if (!is_string($callable) && is_callable($callable)) { + if (!is_string($callable)) { + if (!is_callable($callable)) { + $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0]; + + throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public'); + } $event = $this->checkListenerExpectedEvent($callable, $event); $return = false === call_user_func($callable, $event) ? 1 : 0; } elseif ($this->isComposerScript($callable)) {