From efe5bdb1987411a473d4af15451a376d20928245 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 12 Jun 2026 03:19:34 +0900 Subject: refactor(php-shim): replace literal sprintf calls with format! Convert every sprintf() call with a compile-time literal format string to format!, implementing Display for PhpMixed (delegating to php_to_string) so PhpMixed values render with PHP string semantics through {}. Also merge the format!-wrapped and conditional-literal dynamic sites into single format! calls. Genuinely runtime format strings (table styles, configurable error messages, command synopsis, progress-bar modifiers, regex-built messages) still go through sprintf. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/command/diagnose_command.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/shirabe/src/command/diagnose_command.rs') diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs index 2d6d1eb..aa75ad7 100644 --- a/crates/shirabe/src/command/diagnose_command.rs +++ b/crates/shirabe/src/command/diagnose_command.rs @@ -386,9 +386,9 @@ impl DiagnoseCommand { let limit = arr.get("limit").and_then(|v| v.as_int()).unwrap_or(0); if 10 > remaining { io.write("WARNING"); - io.write(&sprintf( - "GitHub has a rate limit on their API. You currently have %u out of %u requests left.\nSee https://developer.github.com/v3/#rate-limiting and also\n https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens", - &[remaining.into(), limit.into()], + io.write(&format!( + "GitHub has a rate limit on their API. You currently have {} out of {} requests left.\nSee https://developer.github.com/v3/#rate-limiting and also\n https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens", + remaining, limit, )); } else { self.output_result(PhpMixed::Bool(true)); @@ -1288,9 +1288,9 @@ impl DiagnoseCommand { ), other => { return Err(InvalidArgumentException { - message: sprintf( - "DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", - &[other.to_string().into()], + message: format!( + "DiagnoseCommand: Unknown error type \"{}\". Please report at https://github.com/composer/composer/issues/new.", + other.to_string(), ), code: 0, } @@ -1367,9 +1367,9 @@ impl DiagnoseCommand { ), other => { return Err(InvalidArgumentException { - message: sprintf( - "DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", - &[other.to_string().into()], + message: format!( + "DiagnoseCommand: Unknown warning type \"{}\". Please report at https://github.com/composer/composer/issues/new.", + other.to_string(), ), code: 0, } -- cgit v1.3.1