diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-12 03:19:34 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-12 03:19:34 +0900 |
| commit | efe5bdb1987411a473d4af15451a376d20928245 (patch) | |
| tree | 54d3c9e7ab92cfc7d7ec3d90ca3f29e828d929c4 /crates/shirabe/src/installer.rs | |
| parent | 981cae63d9777b877aa9f96907c7995ec020fbf9 (diff) | |
| download | php-shirabe-efe5bdb1987411a473d4af15451a376d20928245.tar.gz php-shirabe-efe5bdb1987411a473d4af15451a376d20928245.tar.zst php-shirabe-efe5bdb1987411a473d4af15451a376d20928245.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer.rs')
| -rw-r--r-- | crates/shirabe/src/installer.rs | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs index 3c68b90..86c9714 100644 --- a/crates/shirabe/src/installer.rs +++ b/crates/shirabe/src/installer.rs @@ -384,9 +384,10 @@ impl Installer { "No replacement was suggested".to_string() }; - self.io.write_error(&sprintf( - "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>", - &[complete.get_pretty_name().into(), replacement.into()], + self.io.write_error(&format!( + "<warning>Package {} is abandoned, you should avoid using it. {}.</warning>", + complete.get_pretty_name(), + replacement, )); } @@ -461,13 +462,11 @@ impl Installer { } } if funding_count > 0 { - self.io.write_error(&sprintf( - "<info>%d package%s you are using %s looking for funding.</info>", - &[ - funding_count.into(), - (if 1 == funding_count { "" } else { "s" }).into(), - (if 1 == funding_count { "is" } else { "are" }).into(), - ], + self.io.write_error(&format!( + "<info>{} package{} you are using {} looking for funding.</info>", + funding_count, + (if 1 == funding_count { "" } else { "s" }), + (if 1 == funding_count { "is" } else { "are" }), )); self.io .write_error("<info>Use the `composer fund` command to find out more!</info>"); @@ -792,16 +791,14 @@ impl Installer { .as_bool() .unwrap_or(false) { - self.io.write_error(&sprintf( - "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>", - &[ - (install_names.len() as i64).into(), - (if 1 == install_names.len() { "" } else { "s" }).into(), - (update_names.len() as i64).into(), - (if 1 == update_names.len() { "" } else { "s" }).into(), - (uninstalls.len() as i64).into(), - (if 1 == uninstalls.len() { "" } else { "s" }).into(), - ], + self.io.write_error(&format!( + "<info>Lock file operations: {} install{}, {} update{}, {} removal{}</info>", + (install_names.len() as i64), + (if 1 == install_names.len() { "" } else { "s" }), + (update_names.len() as i64), + (if 1 == update_names.len() { "" } else { "s" }), + (uninstalls.len() as i64), + (if 1 == uninstalls.len() { "" } else { "s" }), )); if !install_names.is_empty() { self.io.write_error3( @@ -1185,16 +1182,14 @@ impl Installer { if installs.is_empty() && updates.is_empty() && uninstalls.is_empty() { self.io.write_error("Nothing to install, update or remove"); } else { - self.io.write_error(&sprintf( - "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>", - &[ - (installs.len() as i64).into(), - (if 1 == installs.len() { "" } else { "s" }).into(), - (updates.len() as i64).into(), - (if 1 == updates.len() { "" } else { "s" }).into(), - (uninstalls.len() as i64).into(), - (if 1 == uninstalls.len() { "" } else { "s" }).into(), - ], + self.io.write_error(&format!( + "<info>Package operations: {} install{}, {} update{}, {} removal{}</info>", + (installs.len() as i64), + (if 1 == installs.len() { "" } else { "s" }), + (updates.len() as i64), + (if 1 == updates.len() { "" } else { "s" }), + (uninstalls.len() as i64), + (if 1 == uninstalls.len() { "" } else { "s" }), )); if !installs.is_empty() { self.io.write_error3( |
