aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/factory.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-16 16:25:16 +0900
committernsfisis <nsfisis@gmail.com>2026-08-16 17:34:46 +0900
commit5c9bfffcac065f03da57529aed7287b8167d4bef (patch)
treede0f91f4d59b811dc1551d7833c0e2f58d789d9b /crates/shirabe/src/factory.rs
parent5ed66b5485d20203970d594229d32458b3244ebb (diff)
downloadphp-shirabe-5c9bfffcac065f03da57529aed7287b8167d4bef.tar.gz
php-shirabe-5c9bfffcac065f03da57529aed7287b8167d4bef.tar.zst
php-shirabe-5c9bfffcac065f03da57529aed7287b8167d4bef.zip
fix(factory): detect XDG from $_SERVER
Factory::useXdg() enumerates array_keys($_SERVER). The port enumerated the live process environment instead, so a COMPOSER_HOME resolved against keys the PHP side never sees. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/factory.rs')
-rw-r--r--crates/shirabe/src/factory.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs
index b821784d..afdedd81 100644
--- a/crates/shirabe/src/factory.rs
+++ b/crates/shirabe/src/factory.rs
@@ -53,10 +53,11 @@ use crate::util::r#loop::Loop;
use indexmap::IndexMap;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
- InvalidArgumentException, PATHINFO_EXTENSION, PHP_EOL, PHP_OS, PhpMixed, RuntimeException,
- UnexpectedValueException, array_replace_recursive, class_exists, dirname, extension_loaded,
- file_exists, file_get_contents, file_put_contents, implode, is_dir, is_file, json_decode_assoc,
- json_decode_obj, mkdir, pathinfo, realpath, rename, rtrim, strpos, strtr, substr, trim,
+ InvalidArgumentException, PATHINFO_EXTENSION, PHP_EOL, PHP_OS, PHP_SERVER, PhpMixed,
+ RuntimeException, UnexpectedValueException, array_replace_recursive, class_exists, dirname,
+ extension_loaded, file_exists, file_get_contents, file_put_contents, implode, is_dir, is_file,
+ json_decode_assoc, json_decode_obj, mkdir, pathinfo, realpath, rename, rtrim, strpos, strtr,
+ substr, trim,
};
use shirabe_symfony_console::formatter::OutputFormatter;
use shirabe_symfony_console::formatter::OutputFormatterStyle;
@@ -1561,9 +1562,14 @@ impl Factory {
}
fn use_xdg() -> bool {
- // PHP: array_keys($_SERVER) — iterate env-style server vars
- for (key, _) in std::env::vars() {
- if strpos(&key, "XDG_") == Some(0) {
+ let keys: Vec<std::ffi::OsString> = PHP_SERVER
+ .lock()
+ .unwrap()
+ .get_all()
+ .map(|(key, _)| key)
+ .collect();
+ for key in keys {
+ if strpos(&key.to_string_lossy(), "XDG_") == Some(0) {
return true;
}
}