From 4dceac344c299dd4c4c8d4db86bc3bbef2f8d6f2 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sun, 23 Jul 2023 15:35:42 +0900 Subject: [PATCH 1/7] Add the `afterInvoke` hook --- src/Bref.php | 15 ++++++++++++++- src/Runtime/LambdaRuntime.php | 4 ++++ tests/BrefTest.php | 10 ++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Bref.php b/src/Bref.php index 180cdbac6..67cb3eb45 100644 --- a/src/Bref.php +++ b/src/Bref.php @@ -14,6 +14,7 @@ class Bref private static array $hooks = [ 'beforeStartup' => [], 'beforeInvoke' => [], + 'afterInvoke' => [], ]; /** @@ -51,7 +52,19 @@ public static function beforeInvoke(Closure $hook): void } /** - * @param 'beforeStartup'|'beforeInvoke' $hookName + * Register a hook to be executed after any Lambda invocation. + * + * Warning: hooks are low-level extension points to be used by framework + * integrations. For user code, it is not recommended to use them. Use your + * framework's extension points instead. + */ + public static function afterInvoke(Closure $hook): void + { + self::$hooks['afterInvoke'][] = $hook; + } + + /** + * @param 'beforeStartup'|'beforeInvoke'|'afterInvoke' $hookName * * @internal Used by the Bref runtime */ diff --git a/src/Runtime/LambdaRuntime.php b/src/Runtime/LambdaRuntime.php index 6fbadb316..854c57113 100755 --- a/src/Runtime/LambdaRuntime.php +++ b/src/Runtime/LambdaRuntime.php @@ -89,9 +89,13 @@ public function processNextEvent(Handler | RequestHandlerInterface | callable $h $result = $this->invoker->invoke($handler, $event, $context); $this->sendResponse($context->getAwsRequestId(), $result); + + Bref::triggerHooks('afterInvoke'); } catch (Throwable $e) { $this->signalFailure($context->getAwsRequestId(), $e); + Bref::triggerHooks('afterInvoke'); + return false; } diff --git a/tests/BrefTest.php b/tests/BrefTest.php index 4ebbd05cd..37c2696d3 100644 --- a/tests/BrefTest.php +++ b/tests/BrefTest.php @@ -36,6 +36,7 @@ public function test hooks(): void $beforeStartup1 = false; $beforeStartup2 = false; $beforeInvoke = false; + $afterInvoke = false; // Check that we can set multiple handlers Bref::beforeStartup(function () use (&$beforeStartup1) { @@ -47,17 +48,26 @@ public function test hooks(): void Bref::beforeInvoke(function () use (&$beforeInvoke) { return $beforeInvoke = true; }); + Bref::afterInvoke(function () use (&$afterInvoke) { + return $afterInvoke = true; + }); $this->assertFalse($beforeStartup1); $this->assertFalse($beforeStartup2); $this->assertFalse($beforeInvoke); + $this->assertFalse($afterInvoke); Bref::triggerHooks('beforeStartup'); $this->assertTrue($beforeStartup1); $this->assertTrue($beforeStartup2); $this->assertFalse($beforeInvoke); + $this->assertFalse($afterInvoke); Bref::triggerHooks('beforeInvoke'); $this->assertTrue($beforeInvoke); + $this->assertFalse($afterInvoke); + + Bref::triggerHooks('afterInvoke'); + $this->assertTrue($afterInvoke); } } From 9ef553848f0b388017440daa0f0e70ebcd04a9fe Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sun, 23 Jul 2023 23:54:09 +0900 Subject: [PATCH 2/7] Add Bref event subscribers --- src/Bref.php | 25 +++++------- src/ConsoleRuntime/Main.php | 1 + src/FpmRuntime/Main.php | 1 + src/FunctionRuntime/Main.php | 1 + src/Listener/BrefEventSubscriber.php | 52 ++++++++++++++++++++++++ src/Listener/EventDispatcher.php | 56 ++++++++++++++++++++++++++ src/Runtime/LambdaRuntime.php | 5 ++- tests/BrefTest.php | 10 ----- tests/Listener/EventDispatcherTest.php | 31 ++++++++++++++ tests/Listener/FakeSubscriber.php | 27 +++++++++++++ 10 files changed, 183 insertions(+), 26 deletions(-) create mode 100644 src/Listener/BrefEventSubscriber.php create mode 100644 src/Listener/EventDispatcher.php create mode 100644 tests/Listener/EventDispatcherTest.php create mode 100644 tests/Listener/FakeSubscriber.php diff --git a/src/Bref.php b/src/Bref.php index 67cb3eb45..51a0798f9 100644 --- a/src/Bref.php +++ b/src/Bref.php @@ -2,6 +2,7 @@ namespace Bref; +use Bref\Listener\EventDispatcher; use Bref\Runtime\FileHandlerLocator; use Closure; use Psr\Container\ContainerInterface; @@ -14,8 +15,8 @@ class Bref private static array $hooks = [ 'beforeStartup' => [], 'beforeInvoke' => [], - 'afterInvoke' => [], ]; + private static EventDispatcher $eventDispatcher; /** * Configure the container that provides Lambda handlers. @@ -27,6 +28,14 @@ public static function setContainer(Closure $containerProvider): void self::$containerProvider = $containerProvider; } + public static function events(): EventDispatcher + { + if (! isset(self::$eventDispatcher)) { + self::$eventDispatcher = new EventDispatcher(); + } + return self::$eventDispatcher; + } + /** * Register a hook to be executed before the runtime starts. * @@ -52,19 +61,7 @@ public static function beforeInvoke(Closure $hook): void } /** - * Register a hook to be executed after any Lambda invocation. - * - * Warning: hooks are low-level extension points to be used by framework - * integrations. For user code, it is not recommended to use them. Use your - * framework's extension points instead. - */ - public static function afterInvoke(Closure $hook): void - { - self::$hooks['afterInvoke'][] = $hook; - } - - /** - * @param 'beforeStartup'|'beforeInvoke'|'afterInvoke' $hookName + * @param 'beforeStartup'|'beforeInvoke' $hookName * * @internal Used by the Bref runtime */ diff --git a/src/ConsoleRuntime/Main.php b/src/ConsoleRuntime/Main.php index d42435b55..df961a1f2 100755 --- a/src/ConsoleRuntime/Main.php +++ b/src/ConsoleRuntime/Main.php @@ -19,6 +19,7 @@ public static function run(): void LazySecretsLoader::loadSecretEnvironmentVariables(); Bref::triggerHooks('beforeStartup'); + Bref::events()->beforeStartup(); $lambdaRuntime = LambdaRuntime::fromEnvironmentVariable('console'); diff --git a/src/FpmRuntime/Main.php b/src/FpmRuntime/Main.php index 6c8aa842b..ca476a489 100755 --- a/src/FpmRuntime/Main.php +++ b/src/FpmRuntime/Main.php @@ -21,6 +21,7 @@ public static function run(): void LazySecretsLoader::loadSecretEnvironmentVariables(); Bref::triggerHooks('beforeStartup'); + Bref::events()->beforeStartup(); $lambdaRuntime = LambdaRuntime::fromEnvironmentVariable('fpm'); diff --git a/src/FunctionRuntime/Main.php b/src/FunctionRuntime/Main.php index c4843eda4..b121c3f11 100644 --- a/src/FunctionRuntime/Main.php +++ b/src/FunctionRuntime/Main.php @@ -17,6 +17,7 @@ public static function run(): void LazySecretsLoader::loadSecretEnvironmentVariables(); Bref::triggerHooks('beforeStartup'); + Bref::events()->beforeStartup(); $lambdaRuntime = LambdaRuntime::fromEnvironmentVariable('function'); diff --git a/src/Listener/BrefEventSubscriber.php b/src/Listener/BrefEventSubscriber.php new file mode 100644 index 000000000..8d459b3e4 --- /dev/null +++ b/src/Listener/BrefEventSubscriber.php @@ -0,0 +1,52 @@ +subscribers[] = $subscriber; + } + + public function beforeStartup(): void + { + foreach ($this->subscribers as $listener) { + $listener->beforeStartup(); + } + } + + public function beforeInvoke( + Handler|RequestHandlerInterface|callable $handler, + mixed $event, + Context $context, + ): void + { + foreach ($this->subscribers as $listener) { + $listener->beforeInvoke($handler, $event, $context); + } + } + + public function afterInvoke( + Handler|RequestHandlerInterface|callable $handler, + mixed $event, + Context $context, + mixed $result, + Throwable|null $error = null, + ): void + { + foreach ($this->subscribers as $listener) { + $listener->afterInvoke($handler, $event, $context, $result, $error); + } + } +} \ No newline at end of file diff --git a/src/Runtime/LambdaRuntime.php b/src/Runtime/LambdaRuntime.php index 854c57113..bc22d5847 100755 --- a/src/Runtime/LambdaRuntime.php +++ b/src/Runtime/LambdaRuntime.php @@ -82,6 +82,7 @@ public function processNextEvent(Handler | RequestHandlerInterface | callable $h [$event, $context] = $this->waitNextInvocation(); Bref::triggerHooks('beforeInvoke'); + Bref::events()->beforeInvoke($handler, $event, $context); $this->ping(); @@ -90,11 +91,11 @@ public function processNextEvent(Handler | RequestHandlerInterface | callable $h $this->sendResponse($context->getAwsRequestId(), $result); - Bref::triggerHooks('afterInvoke'); + Bref::events()->afterInvoke($handler, $event, $context, $result); } catch (Throwable $e) { $this->signalFailure($context->getAwsRequestId(), $e); - Bref::triggerHooks('afterInvoke'); + Bref::events()->afterInvoke($handler, $event, $context, null, $e); return false; } diff --git a/tests/BrefTest.php b/tests/BrefTest.php index 37c2696d3..4ebbd05cd 100644 --- a/tests/BrefTest.php +++ b/tests/BrefTest.php @@ -36,7 +36,6 @@ public function test hooks(): void $beforeStartup1 = false; $beforeStartup2 = false; $beforeInvoke = false; - $afterInvoke = false; // Check that we can set multiple handlers Bref::beforeStartup(function () use (&$beforeStartup1) { @@ -48,26 +47,17 @@ public function test hooks(): void Bref::beforeInvoke(function () use (&$beforeInvoke) { return $beforeInvoke = true; }); - Bref::afterInvoke(function () use (&$afterInvoke) { - return $afterInvoke = true; - }); $this->assertFalse($beforeStartup1); $this->assertFalse($beforeStartup2); $this->assertFalse($beforeInvoke); - $this->assertFalse($afterInvoke); Bref::triggerHooks('beforeStartup'); $this->assertTrue($beforeStartup1); $this->assertTrue($beforeStartup2); $this->assertFalse($beforeInvoke); - $this->assertFalse($afterInvoke); Bref::triggerHooks('beforeInvoke'); $this->assertTrue($beforeInvoke); - $this->assertFalse($afterInvoke); - - Bref::triggerHooks('afterInvoke'); - $this->assertTrue($afterInvoke); } } diff --git a/tests/Listener/EventDispatcherTest.php b/tests/Listener/EventDispatcherTest.php new file mode 100644 index 000000000..5fbaac3bf --- /dev/null +++ b/tests/Listener/EventDispatcherTest.php @@ -0,0 +1,31 @@ +subscribe($subscriber); + + $eventDispatcher->beforeStartup(); + $this->assertTrue($subscriber->invokedBeforeStartup); + + $handler = fn() => null; + $event = new stdClass; + $context = Context::fake(); + $eventDispatcher->beforeInvoke($handler, $event, $context); + $this->assertEquals([$handler, $event, $context], $subscriber->invokedBeforeInvoke); + + $result = new stdClass; + $eventDispatcher->afterInvoke($handler, $event, $context, $result); + $this->assertEquals([$handler, $event, $context, $result, null], $subscriber->invokedAfterInvoke); + } +} \ No newline at end of file diff --git a/tests/Listener/FakeSubscriber.php b/tests/Listener/FakeSubscriber.php new file mode 100644 index 000000000..ab4e87b9d --- /dev/null +++ b/tests/Listener/FakeSubscriber.php @@ -0,0 +1,27 @@ +invokedBeforeStartup = true; + } + + public function beforeInvoke(...$params): void + { + $this->invokedBeforeInvoke = $params; + } + + public function afterInvoke(...$params): void + { + $this->invokedAfterInvoke = $params; + } +} From 29d2ad4a77b50ec4840c54657527220365538869 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Mon, 24 Jul 2023 20:18:39 +0900 Subject: [PATCH 3/7] Clarify the public vs private API --- src/Listener/EventDispatcher.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Listener/EventDispatcher.php b/src/Listener/EventDispatcher.php index af1a5087e..ff4b9aa46 100644 --- a/src/Listener/EventDispatcher.php +++ b/src/Listener/EventDispatcher.php @@ -7,7 +7,7 @@ use Psr\Http\Server\RequestHandlerInterface; use Throwable; -class EventDispatcher extends BrefEventSubscriber +final class EventDispatcher extends BrefEventSubscriber { /** * @param BrefEventSubscriber[] $subscribers @@ -18,11 +18,19 @@ public function __construct( { } + /** + * Register an event subscriber class. + */ public function subscribe(BrefEventSubscriber $subscriber): void { $this->subscribers[] = $subscriber; } + /** + * Trigger the `beforeStartup` event. + * + * @internal This method is called by Bref and should not be called by user code. + */ public function beforeStartup(): void { foreach ($this->subscribers as $listener) { @@ -30,6 +38,11 @@ public function beforeStartup(): void } } + /** + * Trigger the `beforeInvoke` event. + * + * @internal This method is called by Bref and should not be called by user code. + */ public function beforeInvoke( Handler|RequestHandlerInterface|callable $handler, mixed $event, @@ -41,6 +54,11 @@ public function beforeInvoke( } } + /** + * Trigger the `afterInvoke` event. + * + * @internal This method is called by Bref and should not be called by user code. + */ public function afterInvoke( Handler|RequestHandlerInterface|callable $handler, mixed $event, From 30f7118d634d1397ba742126479be75c3318eaec Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 28 Jul 2023 12:13:13 +0200 Subject: [PATCH 4/7] Add the `afterStartup` event --- src/ConsoleRuntime/Main.php | 2 ++ src/FpmRuntime/Main.php | 2 ++ src/FunctionRuntime/Main.php | 2 ++ src/Listener/BrefEventSubscriber.php | 7 +++++++ src/Listener/EventDispatcher.php | 12 ++++++++++++ 5 files changed, 25 insertions(+) diff --git a/src/ConsoleRuntime/Main.php b/src/ConsoleRuntime/Main.php index df961a1f2..78cc24e02 100755 --- a/src/ConsoleRuntime/Main.php +++ b/src/ConsoleRuntime/Main.php @@ -29,6 +29,8 @@ public static function run(): void $lambdaRuntime->failInitialization("Handler `$handlerFile` doesn't exist"); } + Bref::events()->afterStartup(); + /** @phpstan-ignore-next-line */ while (true) { $lambdaRuntime->processNextEvent(function ($event, Context $context) use ($handlerFile): array { diff --git a/src/FpmRuntime/Main.php b/src/FpmRuntime/Main.php index ca476a489..4e7ae8a25 100755 --- a/src/FpmRuntime/Main.php +++ b/src/FpmRuntime/Main.php @@ -38,6 +38,8 @@ public static function run(): void $lambdaRuntime->failInitialization('Error while starting PHP-FPM', $e); } + Bref::events()->afterStartup(); + /** @phpstan-ignore-next-line */ while (true) { $lambdaRuntime->processNextEvent($phpFpm); diff --git a/src/FunctionRuntime/Main.php b/src/FunctionRuntime/Main.php index b121c3f11..f55de1b78 100644 --- a/src/FunctionRuntime/Main.php +++ b/src/FunctionRuntime/Main.php @@ -29,6 +29,8 @@ public static function run(): void $lambdaRuntime->failInitialization($e->getMessage()); } + Bref::events()->afterStartup(); + $loopMax = getenv('BREF_LOOP_MAX') ?: 1; $loops = 0; while (true) { diff --git a/src/Listener/BrefEventSubscriber.php b/src/Listener/BrefEventSubscriber.php index 8d459b3e4..49f93ca5d 100644 --- a/src/Listener/BrefEventSubscriber.php +++ b/src/Listener/BrefEventSubscriber.php @@ -23,6 +23,13 @@ public function beforeStartup(): void { } + /** + * Register a hook to be executed after the runtime starts. + */ + public function afterStartup(): void + { + } + /** * Register a hook to be executed before any Lambda invocation. */ diff --git a/src/Listener/EventDispatcher.php b/src/Listener/EventDispatcher.php index ff4b9aa46..1f3e94aea 100644 --- a/src/Listener/EventDispatcher.php +++ b/src/Listener/EventDispatcher.php @@ -38,6 +38,18 @@ public function beforeStartup(): void } } + /** + * Trigger the `afterStartup` event. + * + * @internal This method is called by Bref and should not be called by user code. + */ + public function afterStartup(): void + { + foreach ($this->subscribers as $listener) { + $listener->afterStartup(); + } + } + /** * Trigger the `beforeInvoke` event. * From f3bbfd4cdc7615b1f505710f8e4a9a3a668b858f Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 24 Nov 2023 19:10:32 +0100 Subject: [PATCH 5/7] Mark the new event subscribers as experimental for now --- src/Bref.php | 3 +++ src/Listener/BrefEventSubscriber.php | 4 +++- src/Listener/EventDispatcher.php | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Bref.php b/src/Bref.php index 51a0798f9..ed8e5d5cf 100644 --- a/src/Bref.php +++ b/src/Bref.php @@ -12,6 +12,9 @@ class Bref { private static ?Closure $containerProvider = null; private static ?ContainerInterface $container = null; + /** + * TODO deprecate hooks when the event dispatcher is stable. + */ private static array $hooks = [ 'beforeStartup' => [], 'beforeInvoke' => [], diff --git a/src/Listener/BrefEventSubscriber.php b/src/Listener/BrefEventSubscriber.php index 49f93ca5d..163d15411 100644 --- a/src/Listener/BrefEventSubscriber.php +++ b/src/Listener/BrefEventSubscriber.php @@ -13,6 +13,8 @@ * Warning: Bref events are low-level extension points to be used by framework * integrations. For user code, it is not recommended to use them. Use your * framework's extension points instead. + * + * @internal This API is experimental and may change at any time. */ abstract class BrefEventSubscriber { @@ -24,7 +26,7 @@ public function beforeStartup(): void } /** - * Register a hook to be executed after the runtime starts. + * Register a hook to be executed after the runtime has started. */ public function afterStartup(): void { diff --git a/src/Listener/EventDispatcher.php b/src/Listener/EventDispatcher.php index 1f3e94aea..5da5dc635 100644 --- a/src/Listener/EventDispatcher.php +++ b/src/Listener/EventDispatcher.php @@ -7,6 +7,9 @@ use Psr\Http\Server\RequestHandlerInterface; use Throwable; +/** + * @internal This API is experimental and may change at any time. + */ final class EventDispatcher extends BrefEventSubscriber { /** From e3e1f223454dab76fab7c2ee73a0a9e3217f2449 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 24 Nov 2023 19:17:55 +0100 Subject: [PATCH 6/7] Fix CS --- src/Bref.php | 2 +- src/Listener/BrefEventSubscriber.php | 16 +++++++--------- src/Listener/EventDispatcher.php | 19 ++++++++----------- tests/Listener/EventDispatcherTest.php | 4 ++-- tests/Listener/FakeSubscriber.php | 6 ++++++ 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Bref.php b/src/Bref.php index ed8e5d5cf..dcdeb4b9f 100644 --- a/src/Bref.php +++ b/src/Bref.php @@ -34,7 +34,7 @@ public static function setContainer(Closure $containerProvider): void public static function events(): EventDispatcher { if (! isset(self::$eventDispatcher)) { - self::$eventDispatcher = new EventDispatcher(); + self::$eventDispatcher = new EventDispatcher; } return self::$eventDispatcher; } diff --git a/src/Listener/BrefEventSubscriber.php b/src/Listener/BrefEventSubscriber.php index 163d15411..489c3cfbe 100644 --- a/src/Listener/BrefEventSubscriber.php +++ b/src/Listener/BrefEventSubscriber.php @@ -3,9 +3,9 @@ namespace Bref\Listener; use Bref\Context\Context; +// @phpcs:disable use Bref\Event\Handler; use Psr\Http\Server\RequestHandlerInterface; -use Throwable; /** * Listen to Bref internal events. @@ -36,11 +36,10 @@ public function afterStartup(): void * Register a hook to be executed before any Lambda invocation. */ public function beforeInvoke( - Handler|RequestHandlerInterface|callable $handler, + callable | Handler | RequestHandlerInterface $handler, mixed $event, Context $context, - ): void - { + ): void { } /** @@ -50,12 +49,11 @@ public function beforeInvoke( * `$result` will be `null`. */ public function afterInvoke( - Handler|RequestHandlerInterface|callable $handler, + callable | Handler | RequestHandlerInterface $handler, mixed $event, Context $context, mixed $result, - Throwable|null $error = null, - ): void - { + \Throwable | null $error = null, + ): void { } -} \ No newline at end of file +} diff --git a/src/Listener/EventDispatcher.php b/src/Listener/EventDispatcher.php index 5da5dc635..f8da3fe6e 100644 --- a/src/Listener/EventDispatcher.php +++ b/src/Listener/EventDispatcher.php @@ -3,9 +3,9 @@ namespace Bref\Listener; use Bref\Context\Context; +// @phpcs:disable use Bref\Event\Handler; use Psr\Http\Server\RequestHandlerInterface; -use Throwable; /** * @internal This API is experimental and may change at any time. @@ -17,8 +17,7 @@ final class EventDispatcher extends BrefEventSubscriber */ public function __construct( private array $subscribers = [], - ) - { + ) { } /** @@ -59,11 +58,10 @@ public function afterStartup(): void * @internal This method is called by Bref and should not be called by user code. */ public function beforeInvoke( - Handler|RequestHandlerInterface|callable $handler, + callable | Handler | RequestHandlerInterface $handler, mixed $event, Context $context, - ): void - { + ): void { foreach ($this->subscribers as $listener) { $listener->beforeInvoke($handler, $event, $context); } @@ -75,15 +73,14 @@ public function beforeInvoke( * @internal This method is called by Bref and should not be called by user code. */ public function afterInvoke( - Handler|RequestHandlerInterface|callable $handler, + callable | Handler | RequestHandlerInterface $handler, mixed $event, Context $context, mixed $result, - Throwable|null $error = null, - ): void - { + \Throwable | null $error = null, + ): void { foreach ($this->subscribers as $listener) { $listener->afterInvoke($handler, $event, $context, $result, $error); } } -} \ No newline at end of file +} diff --git a/tests/Listener/EventDispatcherTest.php b/tests/Listener/EventDispatcherTest.php index 5fbaac3bf..701753bfb 100644 --- a/tests/Listener/EventDispatcherTest.php +++ b/tests/Listener/EventDispatcherTest.php @@ -18,7 +18,7 @@ public function test subscribe(): void $eventDispatcher->beforeStartup(); $this->assertTrue($subscriber->invokedBeforeStartup); - $handler = fn() => null; + $handler = fn () => null; $event = new stdClass; $context = Context::fake(); $eventDispatcher->beforeInvoke($handler, $event, $context); @@ -28,4 +28,4 @@ public function test subscribe(): void $eventDispatcher->afterInvoke($handler, $event, $context, $result); $this->assertEquals([$handler, $event, $context, $result, null], $subscriber->invokedAfterInvoke); } -} \ No newline at end of file +} diff --git a/tests/Listener/FakeSubscriber.php b/tests/Listener/FakeSubscriber.php index ab4e87b9d..446db1126 100644 --- a/tests/Listener/FakeSubscriber.php +++ b/tests/Listener/FakeSubscriber.php @@ -15,11 +15,17 @@ public function beforeStartup(): void $this->invokedBeforeStartup = true; } + /** + * @param mixed ...$params + */ public function beforeInvoke(...$params): void { $this->invokedBeforeInvoke = $params; } + /** + * @param mixed ...$params + */ public function afterInvoke(...$params): void { $this->invokedAfterInvoke = $params; From 81e3ddca248eefe6a75f445097eab6464ab59380 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 24 Nov 2023 21:03:15 +0100 Subject: [PATCH 7/7] Add phpdoc --- src/Bref.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bref.php b/src/Bref.php index dcdeb4b9f..06d93a52c 100644 --- a/src/Bref.php +++ b/src/Bref.php @@ -31,6 +31,9 @@ public static function setContainer(Closure $containerProvider): void self::$containerProvider = $containerProvider; } + /** + * @internal This API is experimental and may change at any time. + */ public static function events(): EventDispatcher { if (! isset(self::$eventDispatcher)) {