From 695365a0ad68e4534425c64b7a6a4b6598b68ef7 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 4 Aug 2026 04:07:41 +0900 Subject: feat(plugin): dispatch plugin event subscribers through the RPC worker Wires the addPlugin subscriber branch end to end: EventSubscriberInterface and Capable become fallible and dyn-compatible (their sole implementor is the PHP plugin proxy, which answers getSubscribedEvents over RPC), listeners register as Callable::PhpMethod and are invoked with a per-call event handle, and the R table now drops entries when a child-side stub destructs. The R table keeps its IndexMap with monotonically increasing handles, so released handles are never reused and no generation counter is needed. Upstream has no subscriber-plugin test, so the path is covered by a Shirabe-owned fixture exercising all three getSubscribedEvents shapes. Co-Authored-By: Claude Fable 5 --- .../fixtures/subscriber-v1/Subscriber/Plugin.php | 61 ++++++++++++++++++++++ .../plugin/fixtures/subscriber-v1/composer.json | 12 +++++ 2 files changed, 73 insertions(+) create mode 100644 crates/shirabe/tests/plugin/fixtures/subscriber-v1/Subscriber/Plugin.php create mode 100644 crates/shirabe/tests/plugin/fixtures/subscriber-v1/composer.json (limited to 'crates/shirabe/tests/plugin/fixtures') diff --git a/crates/shirabe/tests/plugin/fixtures/subscriber-v1/Subscriber/Plugin.php b/crates/shirabe/tests/plugin/fixtures/subscriber-v1/Subscriber/Plugin.php new file mode 100644 index 00000000..f75763ba --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/subscriber-v1/Subscriber/Plugin.php @@ -0,0 +1,61 @@ +io = $io; + $io->write('activate subscriber-v1'); + } + + public function deactivate(Composer $composer, IOInterface $io) + { + } + + public function uninstall(Composer $composer, IOInterface $io) + { + } + + public static function getSubscribedEvents() + { + return [ + 'post-install-cmd' => 'onPostInstall', + 'shirabe-priority-event' => [['early', 10], ['late', -10]], + 'shirabe-false-event' => ['returnsFalse', 0], + ]; + } + + public function onPostInstall($event) + { + $this->io->write('subscriber saw ' . $event->getName()); + } + + public function early($event) + { + $this->io->write('early listener'); + } + + public function late($event) + { + $this->io->write('late listener'); + } + + public function returnsFalse($event) + { + $this->io->write('failing listener'); + + return false; + } +} diff --git a/crates/shirabe/tests/plugin/fixtures/subscriber-v1/composer.json b/crates/shirabe/tests/plugin/fixtures/subscriber-v1/composer.json new file mode 100644 index 00000000..40659606 --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/subscriber-v1/composer.json @@ -0,0 +1,12 @@ +{ + "name": "subscriber-v1", + "version": "1.0.0", + "type": "composer-plugin", + "autoload": { "psr-0": { "Subscriber": "" } }, + "extra": { + "class": "Subscriber\\Plugin" + }, + "require": { + "composer-plugin-api": "^2.0" + } +} -- cgit v1.3.1