diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-18 04:47:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-18 04:47:18 +0900 |
| commit | ced1f9aa91ee36857fec9664c9ccd86ba2310821 (patch) | |
| tree | 630ea3eb3b0e710403669de9ba6a78a421e182a8 /crates/shirabe/src/console/application.rs | |
| parent | 6b7c6cb9a3d1cdf93f261238c1edbc70706a33c7 (diff) | |
| download | php-shirabe-ced1f9aa91ee36857fec9664c9ccd86ba2310821.tar.gz php-shirabe-ced1f9aa91ee36857fec9664c9ccd86ba2310821.tar.zst php-shirabe-ced1f9aa91ee36857fec9664c9ccd86ba2310821.zip | |
refactor(function-exists): drop checks for always-present capabilities
function_exists() returns false in PHP when a function is blocked by
disable_functions, when its extension is not compiled in, or when the
PHP version predates it. None of those apply to a native binary.
Diffstat (limited to 'crates/shirabe/src/console/application.rs')
| -rw-r--r-- | crates/shirabe/src/console/application.rs | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 54df0b05..d73a1c6b 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -246,7 +246,7 @@ impl Application { // avoid overlapping borrows of self (get_composer needs &mut self). let disk_hint_msg: Option<String> = (|| -> anyhow::Result<Option<String>> { let composer = self.get_composer(false, Some(true), None)?; - if let Some(composer) = composer && function_exists("disk_free_space") { + if let Some(composer) = composer { let composer = composer.borrow_partial(); let config = composer.get_config(); @@ -1536,9 +1536,7 @@ impl Application { input.borrow_mut().set_interactive(false); } - if shirabe_php_shim::function_exists("putenv") { - unsafe { shirabe_php_shim::putenv("SHELL_VERBOSITY", shell_verbosity.to_string()) }; - } + unsafe { shirabe_php_shim::putenv("SHELL_VERBOSITY", shell_verbosity.to_string()) }; shirabe_php_shim::PHP_ENV .lock() .unwrap() @@ -2106,7 +2104,6 @@ impl ApplicationHandle { } let needs_sudo_check = !Platform::is_windows() - && function_exists("exec") && Platform::get_env("COMPOSER_ALLOW_SUPERUSER").is_none() && !Platform::is_docker(); let mut is_non_allowed_root = false; @@ -2243,16 +2240,13 @@ impl ApplicationHandle { if !is_proxy_command { io.write_error3( &format!( - "Running Shirabe {} ({}, based on Composer {}) with PHP {} on {}", + "Running Shirabe {} ({}, based on Composer {}) with PHP {} on {} / {}", composer::SHIRABE_VERSION, composer::SHIRABE_RELEASE_DATE, composer::VERSION, shirabe_php_rpc::get_php_version().version, - (if function_exists("php_uname") { - format!("{} / {}", php_uname("s"), php_uname("r")) - } else { - "Unknown OS".to_string() - }), + php_uname("s"), + php_uname("r"), ), true, io_interface::DEBUG, @@ -2305,11 +2299,7 @@ impl ApplicationHandle { // Check system temp folder for usability as it can cause weird runtime issues otherwise let tempfile_msg: Option<String> = Silencer::call(|| -> anyhow::Result<Option<String>> { - let pid = if function_exists("getmypid") { - format!("{}-", getmypid()) - } else { - String::new() - }; + let pid = format!("{}-", getmypid()); let tempfile = format!( "{}/temp-{}{}", sys_get_temp_dir(), @@ -2688,14 +2678,12 @@ impl ApplicationHandle { output: Option<std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>>, ) -> anyhow::Result<i32> { let application = &self.0; - if shirabe_php_shim::function_exists("putenv") { - let (height, width) = { - let app = application.borrow(); - (app.terminal.get_height(), app.terminal.get_width()) - }; - unsafe { shirabe_php_shim::putenv("LINES", height.to_string()) }; - unsafe { shirabe_php_shim::putenv("COLUMNS", width.to_string()) }; - } + let (height, width) = { + let app = application.borrow(); + (app.terminal.get_height(), app.terminal.get_width()) + }; + unsafe { shirabe_php_shim::putenv("LINES", height.to_string()) }; + unsafe { shirabe_php_shim::putenv("COLUMNS", width.to_string()) }; let input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>> = match input { None => std::rc::Rc::new(std::cell::RefCell::new(ArgvInput::new(None, None)?)), |
