diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-11 20:14:53 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-11 20:14:53 +0900 |
| commit | 8b7abe99d8c351d6f0e83aca9e12bbb8c3ea8182 (patch) | |
| tree | 80678d8c3babf71d8bb8265dac9016bb58c9eba1 /crates | |
| parent | 410858be0520a519531034fcd6c9331a30bc91d2 (diff) | |
| download | php-shirabe-8b7abe99d8c351d6f0e83aca9e12bbb8c3ea8182.tar.gz php-shirabe-8b7abe99d8c351d6f0e83aca9e12bbb8c3ea8182.tar.zst php-shirabe-8b7abe99d8c351d6f0e83aca9e12bbb8c3ea8182.zip | |
refactor(argv): use std::env::args instead of server_argv shim
The server_argv() shim merely wrapped command-line arguments, so call
std::env::args() directly at each use site and drop the unused shim.
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/shirabe-php-shim/src/lib.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/factory.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/main.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/util/platform.rs | 10 |
4 files changed, 7 insertions, 13 deletions
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs index 9255ee7..1bcd03c 100644 --- a/crates/shirabe-php-shim/src/lib.rs +++ b/crates/shirabe-php-shim/src/lib.rs @@ -1820,10 +1820,6 @@ pub fn server_contains_key(_name: &str) -> bool { todo!() } -pub fn server_argv() -> Vec<String> { - todo!() -} - /// PHP superglobal $_ENV access pub fn env_get(_name: &str) -> Option<String> { todo!() diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs index 6d788f4..975c558 100644 --- a/crates/shirabe/src/factory.rs +++ b/crates/shirabe/src/factory.rs @@ -1328,7 +1328,7 @@ impl Factory { static mut WARNED: bool = false; let mut disable_tls = false; // allow running the config command if disable-tls is in the arg list, even if openssl is missing, to allow disabling it via the config command - let argv = shirabe_php_shim::server_argv(); + let argv: Vec<String> = std::env::args().collect(); if !argv.is_empty() && argv.contains(&"disable-tls".to_string()) && (argv.contains(&"conf".to_string()) || argv.contains(&"config".to_string())) diff --git a/crates/shirabe/src/main.rs b/crates/shirabe/src/main.rs index 5c9dd9b..8ba695f 100644 --- a/crates/shirabe/src/main.rs +++ b/crates/shirabe/src/main.rs @@ -2,7 +2,7 @@ use shirabe::console::Application; use shirabe::util::Platform; -use shirabe_php_shim::{realpath, server_argv}; +use shirabe_php_shim::realpath; fn main() { // TODO(phase-c): the full initialization process in composer/bin/composer should be ported @@ -10,7 +10,7 @@ fn main() { Platform::put_env( "COMPOSER_BINARY", - &realpath(&server_argv()[0]).unwrap_or_default(), + &realpath(&std::env::args().next().unwrap_or_default()).unwrap_or_default(), ); // run the command application diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs index 08f5007..ecf2338 100644 --- a/crates/shirabe/src/util/platform.rs +++ b/crates/shirabe/src/util/platform.rs @@ -8,8 +8,8 @@ use shirabe_php_shim::{ PhpMixed, RuntimeException, defined, env_contains_key, env_get, env_set, env_unset, file_exists, file_get_contents, fopen, fstat, function_exists, getcwd, getenv, in_array, ini_get, is_array, is_readable, mb_strlen, php_os_family, posix_geteuid, posix_getpwuid, - posix_getuid, posix_isatty, putenv, realpath, server_argv, server_contains_key, server_get, - server_set, server_unset, stream_isatty, stripos, strlen, strtoupper, substr, usleep, + posix_getuid, posix_isatty, putenv, realpath, server_contains_key, server_get, server_set, + server_unset, stream_isatty, stripos, strlen, strtoupper, substr, usleep, }; use crate::util::ProcessExecutor; @@ -349,11 +349,9 @@ impl Platform { false } - /// @return bool Whether the current command is for bash completion + /// Whether the current command is for bash completion pub fn is_input_completion_process() -> bool { - // PHP: $_SERVER['argv'][1] ?? null - let argv = server_argv(); - argv.get(1).map(|s| s.as_str()) == Some("_complete") + std::env::args().nth(1).as_deref() == Some("_complete") } pub fn workaround_filesystem_issues() { |
