From a2110fa811c8f6c7d1c45a83c6fd1077eb6f3461 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 20 Jul 2026 16:51:45 +0900 Subject: 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. --- crates/shirabe/src/repository/vcs/svn_driver.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/repository/vcs/svn_driver.rs') 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("/"))); -- cgit v1.3.1