Just as an FYI: This discussion is essentially moot with recent revisions of the spec.
We are not defining listener attachment as part of the spec at this time, as there are SOOOOO many ways to accomplish it. Instead, we are defining a `ListenerProviderInterface`, with the single method `getListenersForEvent(EventInterface $event) : iterable`. It is then up to implementations to determine how to populate the set of listeners.
Why are we not defining attachment? Because there's no one way to define it:
- You could do reflection on the callable to determine what the argument to it is in order to determine what it can listen to.
- You could accept an event class name as an argument, along with the listener.
- You could accept an event INSTANCE as an argument, along with the listener.
- You might want to attach listeners using a priority integer, to allow ordering listeners (useful only for the `TaskProcessorInterface`).
- You might want to allow operations such as "first", "last", "before", "after", etc. as mechanisms for ordering listeners (again, only for use with the `TaskProcessorInterface`).
- You might want to allow lazy-loading (i.e., instead of passing a listener callable, you pass a service name and/or a method on that service to call).
There are a ton of options, and we cannot feasibly cover them all in the spec. We CAN cover how to retrieve listeners for the event being dispatched, however. We will LIKELY provide interfaces and/or implementations of providers with different attachment methods in our util package, but these are not and will not be covered by the specification.
Finally, we do not allow arbitrary string event names nor do we define something like a `getName()` method on events. The fully-qualified class name of the event type is definitely enough here, and there are plenty of existing systems out there that demonstrate its effectiveness (e.g., Composer's internal events!). Contrary to your last assertion, `::class` does NOT require an instance to access; you can access it using the FQCN: `Foo\Bar\BazEvent::class`. When the class is imported into the current file, then this becomes even more succinct: `BazEvent::class`. If you HAVE an instance already, great — but for the common case of attaching listeners, you can use one of these FQCN notations instead.
Yes, it DOES require a class is defined, which eliminates the possibility of anonymous class implementations of events... UNLESS they implement specific interfaces. In that situation, your listeners can attach using the interface name (which can ALSO be identified by `::class` notation).