Skip to content

Drop static return type from Events::on()#73

Open
lippserd wants to merge 1 commit intomainfrom
evenement-compat
Open

Drop static return type from Events::on()#73
lippserd wants to merge 1 commit intomainfrom
evenement-compat

Conversation

@lippserd
Copy link
Copy Markdown
Member

@lippserd lippserd commented Apr 7, 2026

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.

@lippserd lippserd added this to the v0.15.1 milestone Apr 7, 2026
@cla-bot cla-bot bot added the cla/signed label Apr 7, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant