diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-21 20:27:13 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-21 20:27:13 +0900 |
| commit | e283399a0304846bbff8484f455c50ecb3de7048 (patch) | |
| tree | 0035845f7d362108b51b9358c8a02465bbdcf7b2 /crates | |
| parent | e4402e52c08b8b28497151302c994793ce885cc3 (diff) | |
| download | php-shirabe-e283399a0304846bbff8484f455c50ecb3de7048.tar.gz php-shirabe-e283399a0304846bbff8484f455c50ecb3de7048.tar.zst php-shirabe-e283399a0304846bbff8484f455c50ecb3de7048.zip | |
refactor(php-shim): drop reset()/reset_first()/end_arr() array helpers
These slice/map wrappers mirrored PHP's internal array pointer and
have no clean Rust equivalent. Remove them and replace the lone
caller with direct first-element access; the rest were unused imports.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/shirabe-php-shim/src/array.rs | 12 | ||||
| -rw-r--r-- | crates/shirabe/src/command/diagnose_command.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/src/config.rs | 6 | ||||
| -rw-r--r-- | crates/shirabe/src/package/locker.rs | 2 |
4 files changed, 6 insertions, 19 deletions
diff --git a/crates/shirabe-php-shim/src/array.rs b/crates/shirabe-php-shim/src/array.rs index e7738cc..7c400fb 100644 --- a/crates/shirabe-php-shim/src/array.rs +++ b/crates/shirabe-php-shim/src/array.rs @@ -701,18 +701,6 @@ pub fn count(value: &PhpMixed) -> usize { } } -pub fn reset<T: Clone>(_array: &[T]) -> Option<T> { - _array.first().cloned() -} - -pub fn reset_first<T: Clone>(_array: &[T]) -> Option<T> { - _array.first().cloned() -} - -pub fn end_arr<V: Clone>(_array: &IndexMap<String, V>) -> Option<V> { - _array.values().last().cloned() -} - pub fn iterator_to_array<I>(iter: I) -> Vec<I::Item> where I: IntoIterator, diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs index 1210956..aff63bd 100644 --- a/crates/shirabe/src/command/diagnose_command.rs +++ b/crates/shirabe/src/command/diagnose_command.rs @@ -15,9 +15,8 @@ use shirabe_php_shim::{ PHP_VERSION, PHP_VERSION_ID, PHP_WINDOWS_VERSION_BUILD, PhpMixed, RuntimeException, count, curl_version, defined, disk_free_space, extension_loaded, file_exists, filter_var_boolean, function_exists, get_class, get_class_err, hash, implode, ini_get, ioncube_loader_iversion, - ioncube_loader_version, is_array, is_string, ob_get_clean, ob_start, phpinfo, reset, rtrim, - sprintf, str_contains, str_replace, str_starts_with, strpos, strstr, strtolower, trim, - version_compare, + ioncube_loader_version, is_array, is_string, ob_get_clean, ob_start, phpinfo, rtrim, sprintf, + str_contains, str_replace, str_starts_with, strpos, strstr, strtolower, trim, version_compare, }; use std::cell::RefCell; use std::rc::Rc; diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs index dfc99a6..68cad87 100644 --- a/crates/shirabe/src/config.rs +++ b/crates/shirabe/src/config.rs @@ -13,8 +13,8 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ E_USER_DEPRECATED, PHP_URL_HOST, PHP_URL_SCHEME, PhpMixed, RuntimeException, array_key_exists, array_merge, array_reverse, array_search_mixed, array_unique, empty, filter_var_url, implode, - in_array, is_array, is_int, is_string, parse_url, php_to_string, reset, rtrim, strtolower, - strtoupper, strtr, substr, trigger_error, + in_array, is_array, is_int, is_string, parse_url, php_to_string, rtrim, strtolower, strtoupper, + strtr, substr, trigger_error, }; use std::cell::RefCell; @@ -866,7 +866,7 @@ impl Config { } } } - let first = reset(&protos); + let first = protos.first().cloned(); if first.as_deref() == Some("http") { return Err(RuntimeException { message: "The http protocol for github is not available anymore, update your config's github-protocols to use \"https\", \"git\" or \"ssh\"".to_string(), diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs index 8237d76..155d5d4 100644 --- a/crates/shirabe/src/package/locker.rs +++ b/crates/shirabe/src/package/locker.rs @@ -8,7 +8,7 @@ use shirabe_external_packages::seld::json_lint::ParsingException; use shirabe_php_shim::{ DATE_RFC3339, LogicException, PhpMixed, RuntimeException, array_intersect, array_keys, array_map, array_merge, file_get_contents, filemtime, function_exists, hash, in_array, is_int, - ksort, realpath, reset_first, sprintf, strcmp, strtolower, touch2, trim, usort, + ksort, realpath, sprintf, strcmp, strtolower, touch2, trim, usort, }; use crate::installer::InstallationManager; |
