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-external-packages/src/symfony/console/cursor.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-external-packages/src/symfony/console/cursor.rs')
| -rw-r--r-- | crates/shirabe-external-packages/src/symfony/console/cursor.rs | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/cursor.rs b/crates/shirabe-external-packages/src/symfony/console/cursor.rs index 9016fab..8474f85 100644 --- a/crates/shirabe-external-packages/src/symfony/console/cursor.rs +++ b/crates/shirabe-external-packages/src/symfony/console/cursor.rs @@ -31,10 +31,7 @@ impl Cursor { pub fn move_up(&self, lines: i64) -> &Self { self.output.borrow().write( - &[shirabe_php_shim::sprintf( - "\x1b[%dA", - &[shirabe_php_shim::PhpMixed::Int(lines)], - )], + &[format!("\x1b[{}A", shirabe_php_shim::PhpMixed::Int(lines),)], false, output_interface::OUTPUT_NORMAL, ); @@ -44,10 +41,7 @@ impl Cursor { pub fn move_down(&self, lines: i64) -> &Self { self.output.borrow().write( - &[shirabe_php_shim::sprintf( - "\x1b[%dB", - &[shirabe_php_shim::PhpMixed::Int(lines)], - )], + &[format!("\x1b[{}B", shirabe_php_shim::PhpMixed::Int(lines),)], false, output_interface::OUTPUT_NORMAL, ); @@ -57,9 +51,9 @@ impl Cursor { pub fn move_right(&self, columns: i64) -> &Self { self.output.borrow().write( - &[shirabe_php_shim::sprintf( - "\x1b[%dC", - &[shirabe_php_shim::PhpMixed::Int(columns)], + &[format!( + "\x1b[{}C", + shirabe_php_shim::PhpMixed::Int(columns), )], false, output_interface::OUTPUT_NORMAL, @@ -70,9 +64,9 @@ impl Cursor { pub fn move_left(&self, columns: i64) -> &Self { self.output.borrow().write( - &[shirabe_php_shim::sprintf( - "\x1b[%dD", - &[shirabe_php_shim::PhpMixed::Int(columns)], + &[format!( + "\x1b[{}D", + shirabe_php_shim::PhpMixed::Int(columns), )], false, output_interface::OUTPUT_NORMAL, @@ -83,10 +77,7 @@ impl Cursor { pub fn move_to_column(&self, column: i64) -> &Self { self.output.borrow().write( - &[shirabe_php_shim::sprintf( - "\x1b[%dG", - &[shirabe_php_shim::PhpMixed::Int(column)], - )], + &[format!("\x1b[{}G", shirabe_php_shim::PhpMixed::Int(column),)], false, output_interface::OUTPUT_NORMAL, ); @@ -96,12 +87,10 @@ impl Cursor { pub fn move_to_position(&self, column: i64, row: i64) -> &Self { self.output.borrow().write( - &[shirabe_php_shim::sprintf( - "\x1b[%d;%dH", - &[ - shirabe_php_shim::PhpMixed::Int(row + 1), - shirabe_php_shim::PhpMixed::Int(column), - ], + &[format!( + "\x1b[{};{}H", + shirabe_php_shim::PhpMixed::Int(row + 1), + shirabe_php_shim::PhpMixed::Int(column), )], false, output_interface::OUTPUT_NORMAL, @@ -243,11 +232,9 @@ impl Cursor { None, ); - shirabe_php_shim::shell_exec(&shirabe_php_shim::sprintf( - "stty %s", - &[shirabe_php_shim::PhpMixed::String( - stty_mode.unwrap_or_default(), - )], + shirabe_php_shim::shell_exec(&format!( + "stty {}", + shirabe_php_shim::PhpMixed::String(stty_mode.unwrap_or_default(),), )); let mut row: i64 = 0; |
