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/tests/config_test.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'crates/shirabe/tests/config_test.rs') diff --git a/crates/shirabe/tests/config_test.rs b/crates/shirabe/tests/config_test.rs index 2d80b625..918da8c2 100644 --- a/crates/shirabe/tests/config_test.rs +++ b/crates/shirabe/tests/config_test.rs @@ -520,7 +520,6 @@ fn test_prohibited_urls_warning_verify_peer() { .unwrap(); } -#[ignore = "Config::get's disable-tls/secure-http/use-github-api/lock branch casts via v.as_bool().unwrap_or(false) instead of PhpMixed::to_bool() (PHP's (bool) cast), so a truthy String(\"true\") is read back as false"] #[test] fn test_disable_tls_can_be_overridden() { let mut config = Config::new(true, None); @@ -547,7 +546,6 @@ fn test_process_timeout() { assert_eq!(PhpMixed::Int(0), result); } -#[ignore = "Config::get's cache-read-only/htaccess-protect branch casts via val.as_bool().unwrap_or_else(|| !val.is_null()) instead of PhpMixed::to_bool() (PHP's (bool) cast), so String(\"0\") from COMPOSER_HTACCESS_PROTECT is read back as true instead of false"] #[test] #[serial] fn test_htaccess_protect() { -- cgit v1.3.1