Skip to content

Commit 7589ff6

Browse files
committed
bug symfony#50111 Fix the list of supported shells for completions in a phar (stof)
This PR was merged into the 5.4 branch. Discussion ---------- Fix the list of supported shells for completions in a phar | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | n/a Using glob inside a phar does not work (it does not find anything). Using a DirectoryIterator on the other hand works with phars. This allows this command to compute the list of supported shells properly when used inside a phar. Easy way to reproduce the bug: run `composer completion unsupported` (or more realistically `composer completion` in a zsh shell as zsh is not a supported shell in symfony/console 5.4) with composer 2.5.5 and see that you get this error with an empty list of supported shells: ``` Detected shell "unsupported", which is not supported by Symfony shell completion (supported shells: ""). ``` Commits ------- aabdc20 Fix the list of supported shells for completions in a phar
2 parents 638703d + aabdc20 commit 7589ff6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Symfony/Component/Console/Command/DumpCompletionCommand.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,14 @@ private function tailDebugLog(string $commandName, OutputInterface $output): voi
132132
*/
133133
private function getSupportedShells(): array
134134
{
135-
return array_map(function ($f) {
136-
return pathinfo($f, \PATHINFO_EXTENSION);
137-
}, glob(__DIR__.'/../Resources/completion.*'));
135+
$shells = [];
136+
137+
foreach (new \DirectoryIterator(__DIR__.'/../Resources/') as $file) {
138+
if (str_starts_with($file->getBasename(), 'completion.') && $file->isFile()) {
139+
$shells[] = $file->getExtension();
140+
}
141+
}
142+
143+
return $shells;
138144
}
139145
}

0 commit comments

Comments
 (0)