aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader
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/downloader
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/downloader')
-rw-r--r--crates/shirabe/src/downloader/git_downloader.rs5
-rw-r--r--crates/shirabe/src/downloader/path_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/svn_downloader.rs8
3 files changed, 6 insertions, 9 deletions
diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs
index 7ca31e24..eaedc453 100644
--- a/crates/shirabe/src/downloader/git_downloader.rs
+++ b/crates/shirabe/src/downloader/git_downloader.rs
@@ -896,8 +896,9 @@ impl VcsDownloader for GitDownloader {
];
let transport_options = package.get_transport_options();
if let Some(git_opts) = transport_options.get("git").and_then(|v| v.as_array())
- && let Some(single) = git_opts.get("single_use_clone").and_then(|v| v.as_bool())
- && single
+ && git_opts
+ .get("single_use_clone")
+ .is_some_and(|v| v.to_bool())
{
clone_flags = vec![];
}
diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs
index eac5a859..d6c5fee7 100644
--- a/crates/shirabe/src/downloader/path_downloader.rs
+++ b/crates/shirabe/src/downloader/path_downloader.rs
@@ -131,7 +131,7 @@ impl PathDownloader {
let mut allowed_strategies = vec![Self::STRATEGY_SYMLINK, Self::STRATEGY_MIRROR];
let mirror_path_repos = Platform::get_env("COMPOSER_MIRROR_PATH_REPOS");
- if mirror_path_repos.is_some_and(|v| !v.is_empty()) {
+ if mirror_path_repos.is_some_and(|v| PhpMixed::String(v).to_bool()) {
current_strategy = Self::STRATEGY_MIRROR;
}
diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs
index 576a2676..e72bd40a 100644
--- a/crates/shirabe/src/downloader/svn_downloader.rs
+++ b/crates/shirabe/src/downloader/svn_downloader.rs
@@ -164,12 +164,8 @@ impl VcsDownloader for SvnDownloader {
let repo_ref = repo.borrow();
if let Some(vcs_repo) = repo_ref.as_any().downcast_ref::<VcsRepository>() {
let repo_config = vcs_repo.get_repo_config();
- if repo_config.contains_key("svn-cache-credentials")
- && let Some(val) = repo_config
- .get("svn-cache-credentials")
- .and_then(|v| v.as_bool())
- {
- self.cache_credentials.set(val);
+ if let Some(val) = repo_config.get("svn-cache-credentials") {
+ self.cache_credentials.set(val.to_bool());
}
}
}