aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/vcs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-20 16:51:45 +0900
committernsfisis <nsfisis@gmail.com>2026-07-20 16:51:45 +0900
commita2110fa811c8f6c7d1c45a83c6fd1077eb6f3461 (patch)
tree620f3cea4ef0c99b5e4a0b7878a59b9e7dbabe36 /crates/shirabe/src/repository/vcs
parent37ed5b8c6d4cda30e668d0221eb281431dbc8c67 (diff)
downloadphp-shirabe-a2110fa811c8f6c7d1c45a83c6fd1077eb6f3461.tar.gz
php-shirabe-a2110fa811c8f6c7d1c45a83c6fd1077eb6f3461.tar.zst
php-shirabe-a2110fa811c8f6c7d1c45a83c6fd1077eb6f3461.zip
fix(php-shim): use PhpMixed::to_bool() for PHP truthy casts
Several call sites coerced PhpMixed to bool via `.as_bool()` (which only matches a literal Bool variant) where the corresponding PHP code does a plain `(bool)` cast or truthy check (isset()/array_key_exists() + implicit bool conversion). This silently dropped truthy non-bool values (e.g. String("true"), String("1"), Int(1)) to their unwrap_or default instead of PHP's actual truthy result. Switched these sites to PhpMixed::to_bool(), which implements PHP's full truthy-cast rules.
Diffstat (limited to 'crates/shirabe/src/repository/vcs')
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs3
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs11
2 files changed, 4 insertions, 10 deletions
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 94daf05c..c7fe5266 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -160,8 +160,7 @@ impl GitHubDriver {
.inner
.repo_config
.get("no-api")
- .and_then(|v| v.as_bool())
- == Some(true)
+ .is_some_and(|v| v.to_bool())
{
self.setup_git_driver(&self.inner.url.clone())?;
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index 5f1faa65..ecf4a48a 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -15,7 +15,7 @@ use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- PhpMixed, RuntimeException, array_key_exists, php_regex, stripos, strrpos, strtr, substr, trim,
+ PhpMixed, RuntimeException, php_regex, stripos, strrpos, strtr, substr, trim,
};
#[derive(Debug)]
@@ -85,13 +85,8 @@ impl SvnDriver {
if let Some(PhpMixed::String(v)) = self.inner.repo_config.get("tags-path").cloned() {
self.tags_path = v;
}
- if array_key_exists("svn-cache-credentials", &self.inner.repo_config) {
- self.cache_credentials = self
- .inner
- .repo_config
- .get("svn-cache-credentials")
- .and_then(|v| v.as_bool())
- .unwrap_or(false);
+ if let Some(v) = self.inner.repo_config.get("svn-cache-credentials") {
+ self.cache_credentials = v.to_bool();
}
if let Some(PhpMixed::String(v)) = self.inner.repo_config.get("package-path").cloned() {
self.package_path = format!("/{}", trim(&v, Some("/")));