From 5ed66b5485d20203970d594229d32458b3244ebb Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 16 Aug 2026 16:24:58 +0900 Subject: fix(php-shim): accept negative offsets in substr_replace The signature took usize, so PHP's negative $start and $length, which count from the end of the string, could not be expressed. Take i64 and an optional length, and apply PHP's clamping rules. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/package/version/version_bumper.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/src/package') diff --git a/crates/shirabe/src/package/version/version_bumper.rs b/crates/shirabe/src/package/version/version_bumper.rs index c0e76520..fcdbf246 100644 --- a/crates/shirabe/src/package/version/version_bumper.rs +++ b/crates/shirabe/src/package/version/version_bumper.rs @@ -112,10 +112,12 @@ impl VersionBumper { } else { format!("{}{}", new_pretty_constraint, suffix) }; - let offset = match_offset as usize; - let length = Platform::strlen(match_str) as usize; - modified = - shirabe_php_shim::substr_replace(&modified, &replacement, offset, length); + modified = shirabe_php_shim::substr_replace( + &modified, + &replacement, + match_offset, + Some(Platform::strlen(match_str)), + ); } let new_constraint = parser.parse_constraints(&modified)?; -- cgit v1.3.1-4-g156e