aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-16 16:24:58 +0900
committernsfisis <nsfisis@gmail.com>2026-08-16 16:47:52 +0900
commit5ed66b5485d20203970d594229d32458b3244ebb (patch)
tree6a88bfa7c127b82ec06406ee7a5b8e29e33e4fcc /crates/shirabe/src
parent5e4bd47bf92e2fe151e3905ee8ab9972c9f70f8d (diff)
downloadphp-shirabe-5ed66b5485d20203970d594229d32458b3244ebb.tar.gz
php-shirabe-5ed66b5485d20203970d594229d32458b3244ebb.tar.zst
php-shirabe-5ed66b5485d20203970d594229d32458b3244ebb.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/package/version/version_bumper.rs10
-rw-r--r--crates/shirabe/src/util/process_executor.rs2
2 files changed, 7 insertions, 5 deletions
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)?;
diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs
index 00091029..875c8810 100644
--- a/crates/shirabe/src/util/process_executor.rs
+++ b/crates/shirabe/src/util/process_executor.rs
@@ -224,7 +224,7 @@ impl ProcessExecutor {
&command_str,
&Self::escape(&Self::get_executable(&m1)),
0,
- strlen(&m1) as usize,
+ Some(strlen(&m1)),
);
}
}