diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-11 23:28:40 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-11 23:28:40 +0900 |
| commit | 38621c67917fd015f884ea04517791cdc5058c6d (patch) | |
| tree | 03f466e2db22a3bc45e20e4f9694eb371a59b0e1 /crates/shirabe-symfony-console/src | |
| parent | 73ab00d3108933c952844b3820f44230c8203807 (diff) | |
| download | php-shirabe-38621c67917fd015f884ea04517791cdc5058c6d.tar.gz php-shirabe-38621c67917fd015f884ea04517791cdc5058c6d.tar.zst php-shirabe-38621c67917fd015f884ea04517791cdc5058c6d.zip | |
chore(php-shim): drop the substring predicate ports
str_contains(), str_starts_with() and str_ends_with() were thin wrappers
over the str methods of the same semantics. Call sites now use
contains()/starts_with()/ends_with() directly.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-symfony-console/src')
7 files changed, 16 insertions, 21 deletions
diff --git a/crates/shirabe-symfony-console/src/completion/completion_input.rs b/crates/shirabe-symfony-console/src/completion/completion_input.rs index aef23d4a..a0adff6c 100644 --- a/crates/shirabe-symfony-console/src/completion/completion_input.rs +++ b/crates/shirabe-symfony-console/src/completion/completion_input.rs @@ -84,7 +84,7 @@ impl CompletionInput { self.completion_name = Some(option.get_name().to_string()); self.completion_value = if !option_value.is_empty() { option_value - } else if !shirabe_php_shim::str_starts_with(&option_token, "--") { + } else if !option_token.starts_with("--") { shirabe_php_shim::substr(&option_token, 2, None) } else { String::new() diff --git a/crates/shirabe-symfony-console/src/formatter/output_formatter.rs b/crates/shirabe-symfony-console/src/formatter/output_formatter.rs index 649af71d..245707d9 100644 --- a/crates/shirabe-symfony-console/src/formatter/output_formatter.rs +++ b/crates/shirabe-symfony-console/src/formatter/output_formatter.rs @@ -34,7 +34,7 @@ impl OutputFormatter { /// Escapes trailing "\" in given text. pub fn escape_trailing_backslash(text: &str) -> String { let mut text = text.to_string(); - if shirabe_php_shim::str_ends_with(&text, "\\") { + if text.ends_with('\\') { let len = shirabe_php_shim::strlen(&text); text = shirabe_php_shim::rtrim(&text, Some("\\")); text = shirabe_php_shim::str_replace("\0", "", &text); diff --git a/crates/shirabe-symfony-console/src/helper/question_helper.rs b/crates/shirabe-symfony-console/src/helper/question_helper.rs index 662edf40..c051fff2 100644 --- a/crates/shirabe-symfony-console/src/helper/question_helper.rs +++ b/crates/shirabe-symfony-console/src/helper/question_helper.rs @@ -557,10 +557,7 @@ impl QuestionHelper { .into_iter() .filter(|m| { ret_for_filter.is_empty() - || shirabe_php_shim::str_starts_with( - &m.to_string(), - &ret_for_filter, - ) + || m.to_string().starts_with(&ret_for_filter) }) .collect(); ofs = -1; @@ -616,7 +613,7 @@ impl QuestionHelper { for value in autocomplete(&ret) { // If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle) - if shirabe_php_shim::str_starts_with(&value.to_string(), &temp_ret) { + if value.to_string().starts_with(&temp_ret) { if (num_matches as usize) < matches.len() { matches[num_matches as usize] = value; } else { @@ -660,7 +657,7 @@ impl QuestionHelper { fn most_recently_entered_value(&self, entered: &str) -> String { // Determine the most recent value that the user entered - if !shirabe_php_shim::str_contains(entered, ",") { + if !entered.contains(',') { return entered.to_string(); } diff --git a/crates/shirabe-symfony-console/src/helper/table.rs b/crates/shirabe-symfony-console/src/helper/table.rs index 177e23c0..06743dbf 100644 --- a/crates/shirabe-symfony-console/src/helper/table.rs +++ b/crates/shirabe-symfony-console/src/helper/table.rs @@ -745,7 +745,7 @@ impl Table { if shirabe_php_shim::strstr(&cell_str, "\n").is_none() { continue; } - let eol = if shirabe_php_shim::str_contains(&cell_str, "\r\n") { + let eol = if cell_str.contains("\r\n") { "\r\n" } else { "\n" @@ -846,7 +846,7 @@ impl Table { let cell_str = cell.to_php_string(); let mut lines = vec![cell.clone()]; if shirabe_php_shim::strstr(&cell_str, "\n").is_some() { - let eol = if shirabe_php_shim::str_contains(&cell_str, "\r\n") { + let eol = if cell_str.contains("\r\n") { "\r\n" } else { "\n" diff --git a/crates/shirabe-symfony-console/src/input/argv_input.rs b/crates/shirabe-symfony-console/src/input/argv_input.rs index cbd0f6d2..200c7384 100644 --- a/crates/shirabe-symfony-console/src/input/argv_input.rs +++ b/crates/shirabe-symfony-console/src/input/argv_input.rs @@ -116,7 +116,7 @@ impl ArgvInput { self.parse_argument(token)?; } else if parse_options && token == "--" { return Ok(false); - } else if parse_options && shirabe_php_shim::str_starts_with(token, "--") { + } else if parse_options && token.starts_with("--") { self.parse_long_option(token)?; } else if parse_options && token.as_bytes().first() == Some(&b'-') && token != "-" { self.parse_short_option(token)?; @@ -405,7 +405,7 @@ impl ArgvInput { let mut is_option = false; for (i, token) in self.tokens.iter().enumerate() { if !token.is_empty() && token.as_bytes()[0] == b'-' { - if shirabe_php_shim::str_contains(token, "=") || self.tokens.get(i + 1).is_none() { + if token.contains('=') || self.tokens.get(i + 1).is_none() { continue; } @@ -458,14 +458,12 @@ impl ArgvInput { // Options with values: // For long options, test for '--option=' at beginning // For short options, test for '-o' at beginning - let leading = if shirabe_php_shim::str_starts_with(value, "--") { + let leading = if value.starts_with("--") { format!("{}=", value) } else { value.clone() }; - if token == value - || (!leading.is_empty() && shirabe_php_shim::str_starts_with(token, &leading)) - { + if token == value || (!leading.is_empty() && token.starts_with(&leading)) { return true; } } @@ -499,12 +497,12 @@ impl ArgvInput { // Options with values: // For long options, test for '--option=' at beginning // For short options, test for '-o' at beginning - let leading = if shirabe_php_shim::str_starts_with(value, "--") { + let leading = if value.starts_with("--") { format!("{}=", value) } else { value.clone() }; - if !leading.is_empty() && shirabe_php_shim::str_starts_with(&token, &leading) { + if !leading.is_empty() && token.starts_with(&leading) { return PhpMixed::String(shirabe_php_shim::substr( &token, shirabe_php_shim::strlen(&leading), diff --git a/crates/shirabe-symfony-console/src/input/array_input.rs b/crates/shirabe-symfony-console/src/input/array_input.rs index d93501c7..e19381a9 100644 --- a/crates/shirabe-symfony-console/src/input/array_input.rs +++ b/crates/shirabe-symfony-console/src/input/array_input.rs @@ -139,9 +139,9 @@ impl ArrayInput { if key == "--" { return Ok(()); } - if shirabe_php_shim::str_starts_with(&key, "--") { + if key.starts_with("--") { self.add_long_option(&shirabe_php_shim::substr(&key, 2, None), value)?; - } else if shirabe_php_shim::str_starts_with(&key, "-") { + } else if key.starts_with("-") { self.add_short_option(&shirabe_php_shim::substr(&key, 1, None), value)?; } else { self.add_argument(&PhpMixed::String(key), value)?; diff --git a/crates/shirabe-symfony-console/src/style/symfony_style.rs b/crates/shirabe-symfony-console/src/style/symfony_style.rs index ead056d5..881d87e0 100644 --- a/crates/shirabe-symfony-console/src/style/symfony_style.rs +++ b/crates/shirabe-symfony-console/src/style/symfony_style.rs @@ -312,7 +312,7 @@ impl SymfonyStyle { fn auto_prepend_text(&mut self) { let fetched = self.buffered_output.fetch(); // Prepend new line if last char isn't EOL: - if !shirabe_php_shim::str_ends_with(&fetched, "\n") { + if !fetched.ends_with('\n') { self.new_line(1); } } |
