From bb4684f7d1c51bc1be9c1bda1b00cb52c839cd25 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 12 Aug 2026 06:29:43 +0900 Subject: feat(php-shim): drop the modelled PHP version constants The shim reported a fixed PHP 8.1.0 through PHP_VERSION, PHP_VERSION_ID, the major/minor/release triple and the PHP_WINDOWS_VERSION_* trio. Their uses split in two. Some guarded branches PHP only needs on runtimes this port cannot be: proc_get_status reports the exit status on every call, so Symfony's pre-8.3 exit-code cache has nothing to work around; hash_raw and hash_file always offer xxh3, so the sha1 fallback is unreachable; and http_get_last_response_headers is always available, so the pre-8.4 $http_response_header branch is gone. safeJunctions reads the host Windows version rather than PHP state, and joins the Windows work on hold. The rest ask about the PHP the user actually runs, and now reach the worker through a new php-rpc PhpVersion payload: the startup banner and the 7.2.5 warning, self-update's min-php filter, the ext-* recommendation in VersionSelector, the stream User-Agent, and whether PhpFileParser scans for enums. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/tests/dependency_resolver/rule_test.rs | 9 ++------- crates/shirabe/tests/package/version/version_selector_test.rs | 7 ++----- 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'crates/shirabe/tests') diff --git a/crates/shirabe/tests/dependency_resolver/rule_test.rs b/crates/shirabe/tests/dependency_resolver/rule_test.rs index 9526bf39..4cd11139 100644 --- a/crates/shirabe/tests/dependency_resolver/rule_test.rs +++ b/crates/shirabe/tests/dependency_resolver/rule_test.rs @@ -7,7 +7,7 @@ use shirabe::dependency_resolver::{ }; use shirabe::package::Link; use shirabe::repository::RepositorySet; -use shirabe_php_shim::{PHP_VERSION_ID, hash_raw}; +use shirabe_php_shim::hash_raw; use shirabe_semver::constraint::MatchAllConstraint; fn root_require_reason() -> ReasonData { @@ -29,12 +29,7 @@ fn generic_rule(literals: Vec) -> Rule { fn test_get_hash() { let rule = generic_rule(vec![123]); - let algo = if PHP_VERSION_ID > 80100 { - "xxh3" - } else { - "sha1" - }; - let binary = hash_raw(algo, "123"); + let binary = hash_raw("xxh3", "123"); let hash = i32::from_ne_bytes(binary[..4].try_into().unwrap()) as i64; assert_eq!(Some(hash), rule.get_hash().unwrap().as_int()); diff --git a/crates/shirabe/tests/package/version/version_selector_test.rs b/crates/shirabe/tests/package/version/version_selector_test.rs index 8a3e44a5..9792e0bf 100644 --- a/crates/shirabe/tests/package/version/version_selector_test.rs +++ b/crates/shirabe/tests/package/version/version_selector_test.rs @@ -16,7 +16,6 @@ use shirabe::package::version::version_parser::VersionParser; use shirabe::repository::PlatformRepository; use shirabe::repository::RepositorySetInterface; use shirabe_php_shim::PhpMixed; -use shirabe_php_shim::{PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION}; use shirabe_semver::constraint::AnyConstraint; use shirabe_symfony_console::output::output_interface; @@ -535,10 +534,8 @@ fn test_false_returned_on_no_packages() { #[test] fn test_find_recommended_require_version() { - let php_version = format!( - "{}.{}.{}", - PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION - ); + let php = shirabe_php_rpc::get_php_version(); + let php_version = format!("{}.{}.{}", php.major, php.minor, php.release); // real version, expected recommendation, [branch-alias], [pkg name] let cases: Vec<(String, &str, Option<&str>, &str)> = vec![ ("1.2.1".to_string(), "^1.2", None, "foo/bar"), -- cgit v1.3.1-4-g156e