From daa1acf091627f4f1af63ad44eee988048fa4136 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 11 Aug 2026 23:52:28 +0900 Subject: chore(php-shim): drop the HHVM_VERSION constant The constant was None and defined("HHVM_VERSION") reports it undefined, so every branch guarded by it was dead: shirabe is a Rust binary and never runs on HHVM. HhvmDetector keeps probing for an `hhvm` binary in PATH, which is what actually produces the hhvm platform package. Two of the dropped branches ask about the PHP runtime that consumes the result rather than about shirabe itself -- the class loader's Hack file lookup and the class map parser's enum scanning -- so both get a TODO(php-runtime) marker. --- crates/shirabe/src/autoload/class_loader.rs | 12 +++++------- crates/shirabe/src/console/application.rs | 8 ++------ crates/shirabe/src/dependency_resolver/problem.rs | 11 ++++------- crates/shirabe/src/platform/hhvm_detector.rs | 8 +------- crates/shirabe/src/util/stream_context_factory.rs | 17 ++++++----------- 5 files changed, 18 insertions(+), 38 deletions(-) (limited to 'crates/shirabe') diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs index 2d888ecf..de03201a 100644 --- a/crates/shirabe/src/autoload/class_loader.rs +++ b/crates/shirabe/src/autoload/class_loader.rs @@ -3,7 +3,7 @@ use indexmap::IndexMap; use shirabe_php_rpc::stream_resolve_include_path; use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, defined, file_exists, include_file, spl_autoload_register, + InvalidArgumentException, PhpMixed, file_exists, include_file, spl_autoload_register, spl_autoload_unregister, strlen, strpos, strrpos, strtr, substr, }; use std::sync::{LazyLock, Mutex}; @@ -340,12 +340,10 @@ impl ClassLoader { // No-op; APCu is not available in Rust. } - let mut file = self.find_file_with_extension(class, ".php"); - - // Search for Hack files if we are running on HHVM - if file.is_none() && defined("HHVM_VERSION") { - file = self.find_file_with_extension(class, ".hh"); - } + // TODO(php-runtime): PHP also looks for a Hack file (`.hh`) when it runs on HHVM. Only the + // worker, which is the runtime that includes the file, can answer whether it is HHVM, and + // asking boots it, while this lookup is what decides whether it is needed at all. + let file = self.find_file_with_extension(class, ".php"); if let Some(apcu_prefix) = &self.apcu_prefix { // No-op; APCu is not available in Rust. diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index b18eaa02..fa9f7edd 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -2259,14 +2259,10 @@ impl ApplicationHandle { if !is_proxy_command { io.write_error3( &format!( - "Running {} ({}) with {} on {}", + "Running {} ({}) with PHP {} on {}", composer::get_version(), composer::RELEASE_DATE, - (if defined("HHVM_VERSION") { - format!("HHVM {}", shirabe_php_shim::HHVM_VERSION.unwrap_or("")) - } else { - format!("PHP {}", PHP_VERSION) - }), + PHP_VERSION, (if function_exists("php_uname") { format!("{} / {}", php_uname("s"), php_uname("r")) } else { diff --git a/crates/shirabe/src/dependency_resolver/problem.rs b/crates/shirabe/src/dependency_resolver/problem.rs index 4510b125..1da6028c 100644 --- a/crates/shirabe/src/dependency_resolver/problem.rs +++ b/crates/shirabe/src/dependency_resolver/problem.rs @@ -12,9 +12,9 @@ use crate::repository::RepositorySet; use indexmap::IndexMap; use shirabe_pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ - CmpOp, LogicException, PhpMixed, defined, extension_loaded, implode, loosely_compare, - php_regex, spl_object_hash, sprintf, str_replace, stripos, strpos, strtolower, substr, - substr_count, version_compare, + CmpOp, LogicException, PhpMixed, extension_loaded, implode, loosely_compare, php_regex, + spl_object_hash, sprintf, str_replace, stripos, strpos, strtolower, substr, substr_count, + version_compare, }; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MultiConstraint; @@ -398,10 +398,7 @@ impl Problem { Self::constraint_to_text(constraint) ); - if defined("HHVM_VERSION") - || (package_name == "hhvm" - && !pool.what_provides(package_name, None).is_empty()) - { + if package_name == "hhvm" && !pool.what_provides(package_name, None).is_empty() { return Ok(( msg, "your HHVM version does not satisfy that requirement.".to_string(), diff --git a/crates/shirabe/src/platform/hhvm_detector.rs b/crates/shirabe/src/platform/hhvm_detector.rs index 26fb5e12..a80b9028 100644 --- a/crates/shirabe/src/platform/hhvm_detector.rs +++ b/crates/shirabe/src/platform/hhvm_detector.rs @@ -2,7 +2,6 @@ use crate::util::Platform; use crate::util::ProcessExecutor; -use shirabe_php_shim::{HHVM_VERSION, defined}; use shirabe_symfony_process::ExecutableFinder; use std::sync::Mutex; @@ -47,13 +46,8 @@ impl HhvmDetectorInterface for HhvmDetector { } let mut cache = HHVM_VERSION_CACHE.lock().unwrap(); - *cache = Some(if defined("HHVM_VERSION") { - HHVM_VERSION.map(|s| s.to_string()) - } else { - None - }); - if cache.as_ref().unwrap().is_none() && !Platform::is_windows() { + if !Platform::is_windows() { *cache = Some(None); let finder = self .executable_finder diff --git a/crates/shirabe/src/util/stream_context_factory.rs b/crates/shirabe/src/util/stream_context_factory.rs index 6a63537d..7706a5cd 100644 --- a/crates/shirabe/src/util/stream_context_factory.rs +++ b/crates/shirabe/src/util/stream_context_factory.rs @@ -9,9 +9,8 @@ use crate::util::http::ProxyManager; use indexmap::IndexMap; use shirabe_ca_bundle::CaBundle; use shirabe_php_shim::{ - HHVM_VERSION, PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, PhpMixed, - array_replace_recursive, extension_loaded, function_exists, php_uname, stream_context_create, - stripos, uasort, + PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, PhpMixed, array_replace_recursive, + extension_loaded, function_exists, php_uname, stream_context_create, stripos, uasort, }; pub struct StreamContextFactory; @@ -148,14 +147,10 @@ impl StreamContextFactory { } } - let php_version = if HHVM_VERSION.is_some() { - format!("HHVM {}", HHVM_VERSION.unwrap()) - } else { - format!( - "PHP {}.{}.{}", - PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION - ) - }; + let php_version = format!( + "PHP {}.{}.{}", + PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION + ); let http_version = if for_curl { // PHP reports `cURL ` here. Shirabe's "curl" transport is backed by reqwest, -- cgit v1.3.1-4-g156e