aboutsummaryrefslogtreecommitdiffhomepage
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
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>
-rw-r--r--crates/shirabe-external-packages/src/symfony/component/finder/spl_file_info.rs6
-rw-r--r--crates/shirabe-php-shim/src/lib.rs4
-rw-r--r--crates/shirabe/src/command/self_update_command.rs19
3 files changed, 13 insertions, 16 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/component/finder/spl_file_info.rs b/crates/shirabe-external-packages/src/symfony/component/finder/spl_file_info.rs
index 31a0e50..3c1be6d 100644
--- a/crates/shirabe-external-packages/src/symfony/component/finder/spl_file_info.rs
+++ b/crates/shirabe-external-packages/src/symfony/component/finder/spl_file_info.rs
@@ -1,6 +1,12 @@
#[derive(Debug)]
pub struct SplFileInfo;
+impl std::fmt::Display for SplFileInfo {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.get_pathname())
+ }
+}
+
impl SplFileInfo {
pub fn new(_path: &str) -> Self {
todo!()
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs
index acc81d9..e87cd2d 100644
--- a/crates/shirabe-php-shim/src/lib.rs
+++ b/crates/shirabe-php-shim/src/lib.rs
@@ -1486,9 +1486,9 @@ pub fn openssl_free_key(_key: PhpMixed) {
todo!()
}
-pub fn iterator_to_array<T>(_iter: T) -> Vec<PhpMixed>
+pub fn iterator_to_array<I>(iter: I) -> Vec<I::Item>
where
- T: IntoIterator<Item = PhpMixed>,
+ I: IntoIterator,
{
todo!()
}
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)