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/repository/vcs/github_driver.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/repository/vcs/github_driver.rs')
| -rw-r--r-- | crates/shirabe/src/repository/vcs/github_driver.rs | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs index aa1e135..5fb3439 100644 --- a/crates/shirabe/src/repository/vcs/github_driver.rs +++ b/crates/shirabe/src/repository/vcs/github_driver.rs @@ -82,9 +82,9 @@ impl GitHubDriver { .unwrap_or(false) { return Err(InvalidArgumentException { - message: sprintf( - "The GitHub repository URL %s is invalid.", - &[PhpMixed::String(self.inner.url.clone())], + message: format!( + "The GitHub repository URL {} is invalid.", + PhpMixed::String(self.inner.url.clone()), ), code: 0, } @@ -366,14 +366,12 @@ impl GitHubDriver { }) { support.insert( "source".to_string(), - Box::new(PhpMixed::String(sprintf( - "https://%s/%s/%s/tree/%s", - &[ - PhpMixed::String(self.inner.origin_url.clone()), - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), - PhpMixed::String(label_str), - ], + Box::new(PhpMixed::String(format!( + "https://{}/{}/{}/tree/{}", + PhpMixed::String(self.inner.origin_url.clone()), + PhpMixed::String(self.owner.clone()), + PhpMixed::String(self.repository.clone()), + PhpMixed::String(label_str), ))), ); } @@ -390,13 +388,11 @@ impl GitHubDriver { }) { support.insert( "issues".to_string(), - Box::new(PhpMixed::String(sprintf( - "https://%s/%s/%s/issues", - &[ - PhpMixed::String(self.inner.origin_url.clone()), - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), - ], + Box::new(PhpMixed::String(format!( + "https://{}/{}/{}/issues", + PhpMixed::String(self.inner.origin_url.clone()), + PhpMixed::String(self.owner.clone()), + PhpMixed::String(self.repository.clone()), ))), ); } @@ -1169,12 +1165,10 @@ impl GitHubDriver { e.get_headers().map(|h| h.as_slice()).unwrap_or(&[]), ); self.inner.io.write_error3( - &sprintf( - "<error>GitHub API limit (%d calls/hr) is exhausted. You are already authorized so you have to wait until %s before doing more requests</error>", - &[ - rate_limit.get("limit").cloned().unwrap_or(PhpMixed::Null), - rate_limit.get("reset").cloned().unwrap_or(PhpMixed::Null), - ], + &format!( + "<error>GitHub API limit ({} calls/hr) is exhausted. You are already authorized so you have to wait until {} before doing more requests</error>", + rate_limit.get("limit").cloned().unwrap_or(PhpMixed::Null), + rate_limit.get("reset").cloned().unwrap_or(PhpMixed::Null), ), true, io_interface::NORMAL, |
