From 0072d771726eda7008b12686c1b68ae53914ee73 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 7 Apr 2026 11:44:57 +0200 Subject: [PATCH] Drop `static` return type from `Events::on()` PHP enforces method signature compatibility when traits are combined in a class hierarchy. Because `EventEmitterTrait` declares `on()` without a return type, any subclass that inherits `on()` from a base using `Events` and also uses `EventEmitterTrait` triggers a fatal error at load time due to the conflicting `: static` annotation. Dropping the return type makes `Events` composable alongside `EventEmitterTrait` in shared class hierarchies. --- src/Events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Events.php b/src/Events.php index 2ef2357..5bd839c 100644 --- a/src/Events.php +++ b/src/Events.php @@ -43,7 +43,7 @@ protected function emitOnce(string $event, array $arguments = []): void * * @throws InvalidArgumentException If the event name is not valid */ - public function on($event, callable $listener): static + public function on($event, callable $listener) { $this->assertValidEvent($event); $this->evenementUnvalidatedOn($event, $listener);