diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-21 20:23:04 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-21 20:23:04 +0900 |
| commit | e4402e52c08b8b28497151302c994793ce885cc3 (patch) | |
| tree | b1a12dd3941c95d1b64ed4f38a38902eecf2ff18 /crates/shirabe/src/config.rs | |
| parent | aa270b53045cc1ce779447f4f19448236e9c4c67 (diff) | |
| download | php-shirabe-e4402e52c08b8b28497151302c994793ce885cc3.tar.gz php-shirabe-e4402e52c08b8b28497151302c994793ce885cc3.tar.zst php-shirabe-e4402e52c08b8b28497151302c994793ce885cc3.zip | |
refactor(php-shim): drop current()/key()/end() array helpers
PHP's internal array pointer (current/key/end) has no clean Rust
equivalent. Remove these todo!() shim stubs and replace each call
site with direct first/last element access matching Composer's
original behavior. Unblocks Config::merge of anonymous {name: false}
disable entries, re-enabling test_add_packagist_repository.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/config.rs')
| -rw-r--r-- | crates/shirabe/src/config.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs index bb46483..dfc99a6 100644 --- a/crates/shirabe/src/config.rs +++ b/crates/shirabe/src/config.rs @@ -12,9 +12,9 @@ use indexmap::IndexMap; 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, current, empty, filter_var_url, - implode, in_array, is_array, is_int, is_string, key, parse_url, php_to_string, reset, rtrim, - strtolower, strtoupper, strtr, substr, trigger_error, + 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, }; use std::cell::RefCell; @@ -465,9 +465,17 @@ impl Config { // disable a repository with an anonymous {"name": false} repo if is_array(repository) && repository.as_array().map(|m| m.len()).unwrap_or(0) == 1 - && matches!(current(repository.clone()), PhpMixed::Bool(false)) + && matches!( + repository.as_array().and_then(|m| m.values().next()), + Some(PhpMixed::Bool(false)) + ) { - self.disable_repo_by_name(&key(repository.clone()).unwrap_or_default()); + let name = repository + .as_array() + .and_then(|m| m.keys().next()) + .cloned() + .unwrap_or_default(); + self.disable_repo_by_name(&name); continue; } |
