diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php
index 603a26e9c..50fd058aa 100644
--- a/src/Composer/Command/ShowCommand.php
+++ b/src/Composer/Command/ShowCommand.php
@@ -815,7 +815,7 @@ EOT
$io->write('homepage : ' . $package->getHomepage());
$io->write('source : ' . sprintf('[%s] %s %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
$io->write('dist : ' . sprintf('[%s] %s %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
- if ($installedRepo->hasPackage($package)) {
+ if (!PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package)) {
$path = $this->requireComposer()->getInstallationManager()->getInstallPath($package);
if (is_string($path)) {
$io->write('path : ' . realpath($path));
@@ -976,7 +976,7 @@ EOT
];
}
- if ($installedRepo->hasPackage($package)) {
+ if (!PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package)) {
$path = $this->requireComposer()->getInstallationManager()->getInstallPath($package);
if (is_string($path)) {
$path = realpath($path);
diff --git a/tests/Composer/Test/Command/ShowCommandTest.php b/tests/Composer/Test/Command/ShowCommandTest.php
index 0e1bf0ada..4dbf25872 100644
--- a/tests/Composer/Test/Command/ShowCommandTest.php
+++ b/tests/Composer/Test/Command/ShowCommandTest.php
@@ -288,12 +288,19 @@ vendor/package 1.1.0 ! 1.2.0", trim($appTester->getDispla
unlink('./composer.json');
unlink('./auth.json');
+ // listing packages
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'show', '-p' => true]);
$output = trim($appTester->getDisplay(true));
foreach (Regex::matchAll('{^(\w+)}m', $output)->matches as $m) {
self::assertTrue(PlatformRepository::isPlatformPackage((string) $m[1]));
}
+
+ // getting a single package
+ $appTester->run(['command' => 'show', '-p' => true, 'package' => 'php']);
+ $appTester->assertCommandIsSuccessful();
+ $appTester->run(['command' => 'show', '-p' => true, '-f' => 'json', 'package' => 'php']);
+ $appTester->assertCommandIsSuccessful();
}
public function testOutdatedWithZeroMajor(): void