aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/self_update_command.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-06 13:52:54 +0900
committernsfisis <nsfisis@gmail.com>2026-06-06 13:52:54 +0900
commit558c22c072d7e7e77e0e5e3493a71727301f7c73 (patch)
tree17848a50e165669774d5fb595cc92f10d6318efc /crates/shirabe/src/command/self_update_command.rs
parentba22d3a98e8f3fbf50274180bfeb870a10d9ae55 (diff)
downloadphp-shirabe-558c22c072d7e7e77e0e5e3493a71727301f7c73.tar.gz
php-shirabe-558c22c072d7e7e77e0e5e3493a71727301f7c73.tar.zst
php-shirabe-558c22c072d7e7e77e0e5e3493a71727301f7c73.zip
fix(self-update-command): resolve finder-related phase-b TODOs
- Add Display for SplFileInfo (PHP (string) cast -> getPathname) and use it in clean_backups instead of a debug-format placeholder. - Generalize iterator_to_array's signature to preserve the element type so get_last_backup_version collects real SplFileInfo and returns the last basename, instead of mapping every entry to PhpMixed::Null. - Drop the stale builder-restructure TODO in get_old_installation_finder. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/self_update_command.rs')
-rw-r--r--crates/shirabe/src/command/self_update_command.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs
index 63e6a0c..1dc8d87 100644
--- a/crates/shirabe/src/command/self_update_command.rs
+++ b/crates/shirabe/src/command/self_update_command.rs
@@ -976,8 +976,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\
if file.get_basename(Some(Self::OLD_INSTALL_EXT)) == except.unwrap_or_default() {
continue;
}
- // TODO(phase-b): SplFileInfo to string conversion (PHP __toString returns the path)
- let file_str = format!("{:?}", file);
+ let file_str = file.to_string();
io.write_error3(
&format!("<info>Removing: {}</info>", file_str),
true,
@@ -990,21 +989,13 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\
pub(crate) fn get_last_backup_version(&self, rollback_dir: &str) -> Option<String> {
let mut finder = self.get_old_installation_finder(rollback_dir);
finder.sort_by_name();
- // TODO(phase-b): iterator_to_array → Vec<PhpMixed>; PHP end() returns last value
- let files = iterator_to_array(finder.into_iter().map(|_| PhpMixed::Null));
-
- if (files.len() as i64) > 0 {
- let last_file = files.last().cloned();
- return last_file
- // PHP: end($files)->getBasename(self::OLD_INSTALL_EXT)
- .and_then(|f| f.as_string().map(|s| s.to_string()));
- }
-
- None
+ let files = iterator_to_array(finder);
+ files
+ .last()
+ .map(|f| f.get_basename(Some(Self::OLD_INSTALL_EXT)))
}
pub(crate) fn get_old_installation_finder(&self, rollback_dir: &str) -> Finder {
- // TODO(phase-b): builder returns &mut Self; restructure to return owned Finder
let mut finder = Finder::create();
finder
.depth(0)