aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/event_dispatcher/event.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-03 01:30:26 +0900
committernsfisis <nsfisis@gmail.com>2026-08-03 01:30:26 +0900
commit20f7a7826ae048d249e0d837ca6393a5f09c9ba6 (patch)
treee35b541857c47543b54afcacf58b82ef3a7cce70 /crates/shirabe/src/event_dispatcher/event.rs
parentbf7ec47524a068c7fa7658f03f4dd44957f492a6 (diff)
downloadphp-shirabe-20f7a7826ae048d249e0d837ca6393a5f09c9ba6.tar.gz
php-shirabe-20f7a7826ae048d249e0d837ca6393a5f09c9ba6.tar.zst
php-shirabe-20f7a7826ae048d249e0d837ca6393a5f09c9ba6.zip
feat(event-dispatcher): run composer.json PHP scripts through the RPC worker
Implement the two script execution paths that previously stopped at todo!(): a Class::method listener is invoked as CallStaticMethod with the event crossing the boundary as a proxy-stub handle, and a Command-class listener runs inside a throwaway bare Symfony Application hosted by the worker via a generated snippet, its BufferedOutput written back through the dispatcher's IO. makeAutoloader is ported for real (canonical-package hash, setDevMode, buildPackageMap/parseAutoloads/createLoader), and the class_exists/is_callable/is_a/defined guards now query the worker, whose script autoloader resolves classes by asking the Rust-side ClassLoader over the reverse channel. EventInterface gains as_any (the IOInterface downcast pattern) so the concrete event type is reachable behind the trait object. Application::do_run now registers ScriptAliasCommand entries as typed commands, unblocking the run-script --list/alias tests; the dev-mode-to-generator test is ported with local mockall mocks. The remaining ignored tests carry re-verified reasons: the listener methods live on the PHPUnit test class itself (unloadable in the worker), or the test needs live import of a user PHP Command class into the Application. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/event_dispatcher/event.rs')
-rw-r--r--crates/shirabe/src/event_dispatcher/event.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/shirabe/src/event_dispatcher/event.rs b/crates/shirabe/src/event_dispatcher/event.rs
index f04839f6..7075ada0 100644
--- a/crates/shirabe/src/event_dispatcher/event.rs
+++ b/crates/shirabe/src/event_dispatcher/event.rs
@@ -47,6 +47,9 @@ impl Event {
}
pub trait EventInterface: std::fmt::Debug {
+ /// For downcasting to the concrete event type (PHP `instanceof`), mirroring
+ /// `IOInterface::as_any`.
+ fn as_any(&self) -> &dyn std::any::Any;
fn get_name(&self) -> &str;
fn get_arguments(&self) -> &Vec<String>;
fn get_flags(&self) -> &IndexMap<String, PhpMixed>;
@@ -55,6 +58,10 @@ pub trait EventInterface: std::fmt::Debug {
}
impl EventInterface for Event {
+ fn as_any(&self) -> &dyn std::any::Any {
+ self
+ }
+
fn get_name(&self) -> &str {
&self.name
}