Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;

use function array_diff;
use function array_key_exists;
use function array_keys;
use function array_walk;
use function count;
use function file_exists;
use function sprintf;
use function substr;
Expand Down Expand Up @@ -88,14 +91,15 @@ public function execute(InputInterface $input, OutputInterface $output): int
$phpEnabledExtensions = $targetPlatform->phpBinaryPath->extensions();
$extensionPath = $targetPlatform->phpBinaryPath->extensionPath();
$extensionEnding = $targetPlatform->operatingSystem === OperatingSystem::Windows ? '.dll' : '.so';
$piePackagesMatched = [];

$output->writeln(sprintf(
"\n" . '<options=bold,underscore>%s:</>',
$showAll ? 'All loaded extensions' : 'Loaded PIE extensions',
));
array_walk(
$phpEnabledExtensions,
static function (string $version, string $phpExtensionName) use ($showAll, $output, $piePackages, $extensionPath, $extensionEnding): void {
static function (string $version, string $phpExtensionName) use ($showAll, $output, $piePackages, $extensionPath, $extensionEnding, &$piePackagesMatched): void {
if (! array_key_exists($phpExtensionName, $piePackages)) {
if ($showAll) {
$output->writeln(sprintf(' <comment>%s:%s</comment>', $phpExtensionName, $version));
Expand All @@ -104,7 +108,8 @@ static function (string $version, string $phpExtensionName) use ($showAll, $outp
return;
}

$piePackage = $piePackages[$phpExtensionName];
$piePackage = $piePackages[$phpExtensionName];
$piePackagesMatched[] = $phpExtensionName;

$output->writeln(sprintf(
' <info>%s:%s</info> (from 🥧 <info>%s</info>%s)',
Expand All @@ -121,6 +126,21 @@ static function (string $version, string $phpExtensionName) use ($showAll, $outp
},
);

if (! $showAll && ! count($piePackagesMatched)) {
$output->writeln('(none)');
}

$unmatchedPiePackages = array_diff(array_keys($piePackages), $piePackagesMatched);

if (count($unmatchedPiePackages)) {
$output->writeln("\n" . ' ⚠️ <options=bold,underscore>PIE packages not loaded:</>');
$output->writeln('These extensions were installed with PIE but are not currently enabled.' . "\n");

foreach ($unmatchedPiePackages as $unmatchedPiePackage) {
$output->writeln(sprintf(' - %s', $piePackages[$unmatchedPiePackage]->prettyNameAndVersion()));
}
}

return Command::SUCCESS;
}

Expand Down