aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/config.rs
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/config.rs
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/config.rs')
-rw-r--r--crates/shirabe/src/config.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs
index 8f78ecca..c389063b 100644
--- a/crates/shirabe/src/config.rs
+++ b/crates/shirabe/src/config.rs
@@ -637,8 +637,7 @@ impl Config {
};
Ok(PhpMixed::Bool(
- val.as_string() != Some("false")
- && val.as_bool().unwrap_or_else(|| !val.is_null()),
+ val.as_string() != Some("false") && val.to_bool(),
))
}
@@ -653,7 +652,7 @@ impl Config {
let v = self.config.get(key).cloned().unwrap_or(PhpMixed::Null);
Ok(PhpMixed::Bool(
- v.as_string() != Some("false") && v.as_bool().unwrap_or(false),
+ v.as_string() != Some("false") && v.to_bool(),
))
}
@@ -1179,8 +1178,8 @@ impl Config {
.get("ssl")
.and_then(|v| v.as_array())
.and_then(|m| m.get("verify_peer"));
- if let Some(v) = verify_peer
- && v.as_bool() == Some(false)
+ if let Some(v) = verify_peer.and_then(|v| v.as_opt())
+ && !v.to_bool()
{
warning = Some("verify_peer".to_string());
}
@@ -1189,8 +1188,8 @@ impl Config {
.get("ssl")
.and_then(|v| v.as_array())
.and_then(|m| m.get("verify_peer_name"));
- if let Some(v) = verify_peer_name
- && v.as_bool() == Some(false)
+ if let Some(v) = verify_peer_name.and_then(|v| v.as_opt())
+ && !v.to_bool()
{
warning = match warning {
None => Some("verify_peer_name".to_string()),