From 20f7a7826ae048d249e0d837ca6393a5f09c9ba6 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 3 Aug 2026 01:30:26 +0900 Subject: 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 --- crates/shirabe/src/plugin/command_event.rs | 4 ++++ crates/shirabe/src/plugin/post_file_download_event.rs | 4 ++++ crates/shirabe/src/plugin/pre_command_run_event.rs | 4 ++++ crates/shirabe/src/plugin/pre_file_download_event.rs | 4 ++++ crates/shirabe/src/plugin/pre_pool_create_event.rs | 4 ++++ 5 files changed, 20 insertions(+) (limited to 'crates/shirabe/src/plugin') diff --git a/crates/shirabe/src/plugin/command_event.rs b/crates/shirabe/src/plugin/command_event.rs index ca63461d..afd93fbb 100644 --- a/crates/shirabe/src/plugin/command_event.rs +++ b/crates/shirabe/src/plugin/command_event.rs @@ -60,6 +60,10 @@ impl CommandEvent { } impl EventInterface for CommandEvent { + fn as_any(&self) -> &dyn std::any::Any { + self + } + fn get_name(&self) -> &str { self.inner.get_name() } diff --git a/crates/shirabe/src/plugin/post_file_download_event.rs b/crates/shirabe/src/plugin/post_file_download_event.rs index 88fc181b..a9cadc44 100644 --- a/crates/shirabe/src/plugin/post_file_download_event.rs +++ b/crates/shirabe/src/plugin/post_file_download_event.rs @@ -60,6 +60,10 @@ impl PostFileDownloadEvent { } impl EventInterface for PostFileDownloadEvent { + fn as_any(&self) -> &dyn std::any::Any { + self + } + fn get_name(&self) -> &str { self.inner.get_name() } diff --git a/crates/shirabe/src/plugin/pre_command_run_event.rs b/crates/shirabe/src/plugin/pre_command_run_event.rs index 854c47f0..50a182b6 100644 --- a/crates/shirabe/src/plugin/pre_command_run_event.rs +++ b/crates/shirabe/src/plugin/pre_command_run_event.rs @@ -42,6 +42,10 @@ impl PreCommandRunEvent { } impl EventInterface for PreCommandRunEvent { + fn as_any(&self) -> &dyn std::any::Any { + self + } + fn get_name(&self) -> &str { self.inner.get_name() } diff --git a/crates/shirabe/src/plugin/pre_file_download_event.rs b/crates/shirabe/src/plugin/pre_file_download_event.rs index 9ec74a07..73d59a5b 100644 --- a/crates/shirabe/src/plugin/pre_file_download_event.rs +++ b/crates/shirabe/src/plugin/pre_file_download_event.rs @@ -78,6 +78,10 @@ impl PreFileDownloadEvent { } impl EventInterface for PreFileDownloadEvent { + fn as_any(&self) -> &dyn std::any::Any { + self + } + fn get_name(&self) -> &str { self.inner.get_name() } diff --git a/crates/shirabe/src/plugin/pre_pool_create_event.rs b/crates/shirabe/src/plugin/pre_pool_create_event.rs index 0ffde945..9547ac8b 100644 --- a/crates/shirabe/src/plugin/pre_pool_create_event.rs +++ b/crates/shirabe/src/plugin/pre_pool_create_event.rs @@ -95,6 +95,10 @@ impl PrePoolCreateEvent { } impl EventInterface for PrePoolCreateEvent { + fn as_any(&self) -> &dyn std::any::Any { + self + } + fn get_name(&self) -> &str { self.inner.get_name() } -- cgit v1.3.1