Skip to content

Commit aabdc20

Browse files
committed
Fix the list of supported shells for completions in a phar
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.
1 parent 638703d commit aabdc20

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

+9-3
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)