aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src/runtime.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-25 13:43:49 +0900
committernsfisis <nsfisis@gmail.com>2026-06-25 23:47:47 +0900
commit4573629d9fc7321171cd8b134e68869950b02045 (patch)
tree1c1786537f71c6c61bca5fb0bba90fe1e722eac0 /crates/shirabe-php-shim/src/runtime.rs
parent8d6b521e0034d1bcba594921ebc4f74e87e5ef46 (diff)
downloadphp-shirabe-4573629d9fc7321171cd8b134e68869950b02045.tar.gz
php-shirabe-4573629d9fc7321171cd8b134e68869950b02045.tar.zst
php-shirabe-4573629d9fc7321171cd8b134e68869950b02045.zip
feat(semver): hand-port constraint AND-split to drop look-around regex
The PCRE delimiter `(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)` used to split AND-constraints relies on look-around, which the regex crate cannot compile (parse_constraints panicked). Reproduce its semantics in a hand-written `split_and_constraints` scanner shared by VersionParser and RootPackageLoader. Also model `method_exists` for the class-name form (shirabe runs no dumped Composer ClassLoader) and un-ignore the InstalledVersions tests, serialized via `#[serial]` since they share global static state. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src/runtime.rs')
-rw-r--r--crates/shirabe-php-shim/src/runtime.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/shirabe-php-shim/src/runtime.rs b/crates/shirabe-php-shim/src/runtime.rs
index bf4d355..c1c5f61 100644
--- a/crates/shirabe-php-shim/src/runtime.rs
+++ b/crates/shirabe-php-shim/src/runtime.rs
@@ -71,9 +71,16 @@ pub fn defined(name: &str) -> bool {
)
}
-pub fn method_exists(_object: &PhpMixed, _method_name: &str) -> bool {
- // TODO(phase-d): requires runtime class/method reflection, which PhpMixed::Object does not carry.
- todo!()
+// Models methods available on Composer's own runtime classes when given a class name string.
+// Shirabe is a native binary that does not run under a Composer-dumped autoloader, so the dumped
+// `Composer\Autoload\ClassLoader` (and its `getRegisteredLoaders`) is absent from the running
+// process; the class-name form therefore reports no such method. The object form needs runtime
+// reflection that PhpMixed::Object does not carry.
+pub fn method_exists(object_or_class: &PhpMixed, _method_name: &str) -> bool {
+ match object_or_class {
+ PhpMixed::String(_) => false,
+ _ => todo!(),
+ }
}
// Models the classes available in a standard PHP CLI environment running Composer: