aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-29 21:56:39 +0900
committernsfisis <nsfisis@gmail.com>2026-06-29 21:58:35 +0900
commit91ccd49cf68bca199e7d41fa65a4a3b0d1368127 (patch)
tree77206f45d192ba27f2d322d2cb1df89f0e4c6dc3 /crates/shirabe-external-packages/src/symfony
parentff90c6b259f597a17d73aaf5c3a437bfdda3e68e (diff)
downloadphp-shirabe-91ccd49cf68bca199e7d41fa65a4a3b0d1368127.tar.gz
php-shirabe-91ccd49cf68bca199e7d41fa65a4a3b0d1368127.tar.zst
php-shirabe-91ccd49cf68bca199e7d41fa65a4a3b0d1368127.zip
feat(php-shim): implement DirectoryIterator in fs shim
Give DirectoryIteratorEntry a backing path (mirroring RecursiveIteratorFileInfo) and make directory_iterator enumerate entries, returning Result to match PHP DirectoryIterator's UnexpectedValueException on an unopenable directory. Wire the new Result through DumpCompletionCommand's get_supported_shells. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony')
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs
index 588b868..8e2583e 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/dump_completion_command.rs
@@ -63,12 +63,12 @@ impl DumpCompletionCommand {
pub fn complete_impl(&self, input: &CompletionInput, suggestions: &mut CompletionSuggestions) {
if input.must_suggest_argument_values_for("shell") {
- suggestions.suggest_values(
- self.get_supported_shells()
- .into_iter()
- .map(StringOrSuggestion::String)
- .collect(),
- );
+ // TODO(phase-d): PHP's complete() lets a DirectoryIterator failure propagate, but the
+ // Command::complete trait is infallible; on error the suggestions are skipped instead.
+ if let Ok(shells) = self.get_supported_shells() {
+ suggestions
+ .suggest_values(shells.into_iter().map(StringOrSuggestion::String).collect());
+ }
}
}
@@ -98,14 +98,14 @@ impl DumpCompletionCommand {
todo!()
}
- fn get_supported_shells(&self) -> Vec<String> {
+ fn get_supported_shells(&self) -> anyhow::Result<Vec<String>> {
let mut shells = vec![];
// foreach (new \DirectoryIterator(__DIR__.'/../Resources/') as $file)
for file in shirabe_php_shim::directory_iterator(&format!(
"{}/../Resources/",
shirabe_php_shim::dir()
- )) {
+ ))? {
if shirabe_php_shim::str_starts_with(&file.get_basename(), "completion.")
&& file.is_file()
{
@@ -113,7 +113,7 @@ impl DumpCompletionCommand {
}
}
- shells
+ Ok(shells)
}
}
@@ -209,7 +209,7 @@ impl Command for DumpCompletionCommand {
shell
);
if !shirabe_php_shim::file_exists(&completion_file) {
- let supported_shells = self.get_supported_shells();
+ let supported_shells = self.get_supported_shells()?;
// TODO: PHP does `$output instanceof ConsoleOutputInterface ? $output->getErrorOutput()
// : $output`. There is no way to test trait membership through `&dyn OutputInterface`