2020use Symfony \Component \Console \Output \NullOutput ;
2121use Symfony \Component \Console \Output \OutputInterface ;
2222
23+ use function array_diff ;
2324use function array_key_exists ;
25+ use function array_keys ;
2426use function array_walk ;
27+ use function count ;
2528use function file_exists ;
2629use function sprintf ;
2730use function substr ;
@@ -88,14 +91,15 @@ public function execute(InputInterface $input, OutputInterface $output): int
8891 $ phpEnabledExtensions = $ targetPlatform ->phpBinaryPath ->extensions ();
8992 $ extensionPath = $ targetPlatform ->phpBinaryPath ->extensionPath ();
9093 $ extensionEnding = $ targetPlatform ->operatingSystem === OperatingSystem::Windows ? '.dll ' : '.so ' ;
94+ $ piePackagesMatched = [];
9195
9296 $ output ->writeln (sprintf (
9397 "\n" . '<options=bold,underscore>%s:</> ' ,
9498 $ showAll ? 'All loaded extensions ' : 'Loaded PIE extensions ' ,
9599 ));
96100 array_walk (
97101 $ phpEnabledExtensions ,
98- static function (string $ version , string $ phpExtensionName ) use ($ showAll , $ output , $ piePackages , $ extensionPath , $ extensionEnding ): void {
102+ static function (string $ version , string $ phpExtensionName ) use ($ showAll , $ output , $ piePackages , $ extensionPath , $ extensionEnding, & $ piePackagesMatched ): void {
99103 if (! array_key_exists ($ phpExtensionName , $ piePackages )) {
100104 if ($ showAll ) {
101105 $ output ->writeln (sprintf (' <comment>%s:%s</comment> ' , $ phpExtensionName , $ version ));
@@ -104,7 +108,8 @@ static function (string $version, string $phpExtensionName) use ($showAll, $outp
104108 return ;
105109 }
106110
107- $ piePackage = $ piePackages [$ phpExtensionName ];
111+ $ piePackage = $ piePackages [$ phpExtensionName ];
112+ $ piePackagesMatched [] = $ phpExtensionName ;
108113
109114 $ output ->writeln (sprintf (
110115 ' <info>%s:%s</info> (from 🥧 <info>%s</info>%s) ' ,
@@ -121,6 +126,21 @@ static function (string $version, string $phpExtensionName) use ($showAll, $outp
121126 },
122127 );
123128
129+ if (! $ showAll && ! count ($ piePackagesMatched )) {
130+ $ output ->writeln ('(none) ' );
131+ }
132+
133+ $ unmatchedPiePackages = array_diff (array_keys ($ piePackages ), $ piePackagesMatched );
134+
135+ if (count ($ unmatchedPiePackages )) {
136+ $ output ->writeln ("\n" . ' ⚠️ <options=bold,underscore>PIE packages not loaded:</> ' );
137+ $ output ->writeln ('These extensions were installed with PIE but are not currently enabled. ' . "\n" );
138+
139+ foreach ($ unmatchedPiePackages as $ unmatchedPiePackage ) {
140+ $ output ->writeln (sprintf (' - %s ' , $ piePackages [$ unmatchedPiePackage ]->prettyNameAndVersion ()));
141+ }
142+ }
143+
124144 return Command::SUCCESS ;
125145 }
126146
0 commit comments