From f749a47804cd296a3059cd3f8079c62dbaa5fdc0 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 7 Aug 2026 07:26:48 +0900 Subject: refactor: merge split inherent impl blocks into one per type Enable clippy::multiple_inherent_impl and fix the 21 sites it reports. Types whose inherent methods were spread across two or three impl blocks now keep them in a single block; only the impl headers move, no method bodies change. Co-Authored-By: Claude Opus 5 (1M context) --- .../src/symfony/console/input/array_input.rs | 118 ++++++++++----------- .../src/symfony/console/style/symfony_style.rs | 2 - 2 files changed, 58 insertions(+), 62 deletions(-) (limited to 'crates/shirabe-external-packages/src') diff --git a/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs b/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs index 1ae7069d..9a19b839 100644 --- a/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs +++ b/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs @@ -130,67 +130,7 @@ impl ArrayInput { default } -} - -/// Returns a stringified representation of the args passed to the command. -impl std::fmt::Display for ArrayInput { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let mut params: Vec = vec![]; - for (param, val) in &self.parameters { - // $param && \is_string($param) && '-' === $param[0] - let is_option_key = - matches!(param, PhpMixed::String(s) if !s.is_empty() && s.as_bytes()[0] == b'-'); - if is_option_key { - let param = param.as_string().unwrap(); - let glue = if param.as_bytes().get(1) == Some(&b'-') { - "=" - } else { - " " - }; - if let PhpMixed::List(list) = val { - for v in list { - let v = shirabe_php_shim::php_to_string(v); - params.push(format!( - "{}{}", - param, - if !v.is_empty() { - format!("{}{}", glue, self.inner.escape_token(&v)) - } else { - String::new() - } - )); - } - } else { - let val = shirabe_php_shim::php_to_string(val); - params.push(format!( - "{}{}", - param, - if !val.is_empty() { - format!("{}{}", glue, self.inner.escape_token(&val)) - } else { - String::new() - } - )); - } - } else if let PhpMixed::List(list) = val { - let escaped: Vec = list - .iter() - .map(|v| self.inner.escape_token(&shirabe_php_shim::php_to_string(v))) - .collect(); - params.push(shirabe_php_shim::implode(" ", &escaped)); - } else { - params.push( - self.inner - .escape_token(&shirabe_php_shim::php_to_string(val)), - ); - } - } - - write!(f, "{}", shirabe_php_shim::implode(" ", ¶ms)) - } -} -impl ArrayInput { fn parse(&mut self) -> anyhow::Result<()> { // Clone to avoid borrowing self while mutating; PHP iterates over a copy semantically. let parameters = self.parameters.clone(); @@ -296,6 +236,64 @@ impl ArrayInput { } } +/// Returns a stringified representation of the args passed to the command. +impl std::fmt::Display for ArrayInput { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut params: Vec = vec![]; + for (param, val) in &self.parameters { + // $param && \is_string($param) && '-' === $param[0] + let is_option_key = + matches!(param, PhpMixed::String(s) if !s.is_empty() && s.as_bytes()[0] == b'-'); + if is_option_key { + let param = param.as_string().unwrap(); + let glue = if param.as_bytes().get(1) == Some(&b'-') { + "=" + } else { + " " + }; + if let PhpMixed::List(list) = val { + for v in list { + let v = shirabe_php_shim::php_to_string(v); + params.push(format!( + "{}{}", + param, + if !v.is_empty() { + format!("{}{}", glue, self.inner.escape_token(&v)) + } else { + String::new() + } + )); + } + } else { + let val = shirabe_php_shim::php_to_string(val); + params.push(format!( + "{}{}", + param, + if !val.is_empty() { + format!("{}{}", glue, self.inner.escape_token(&val)) + } else { + String::new() + } + )); + } + } else if let PhpMixed::List(list) = val { + let escaped: Vec = list + .iter() + .map(|v| self.inner.escape_token(&shirabe_php_shim::php_to_string(v))) + .collect(); + params.push(shirabe_php_shim::implode(" ", &escaped)); + } else { + params.push( + self.inner + .escape_token(&shirabe_php_shim::php_to_string(val)), + ); + } + } + + write!(f, "{}", shirabe_php_shim::implode(" ", ¶ms)) + } +} + impl InputInterface for ArrayInput { fn dup(&self) -> std::rc::Rc> { std::rc::Rc::new(std::cell::RefCell::new(self.clone())) diff --git a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs index 9097faff..b62c2565 100644 --- a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs +++ b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs @@ -479,9 +479,7 @@ impl SymfonyStyle { as Box) -> Result> }) } -} -impl SymfonyStyle { /// {@inheritdoc} pub fn writeln(&mut self, messages: PhpMixed, r#type: i64) { let messages: Vec = if !shirabe_php_shim::is_iterable(&messages) { -- cgit v1.3.1