aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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)