On 16/11/2016 09:32, Quim Calpe wrote:
class EventHandler {
    public function handle(Event $event) {
        if ($event instanceof ProductCreated) {
            ...
        } elseif ($event instanceof ProductNameChanged) {
            ...
        }
    }
}

I don't see much wrong with this; the intent is very clear. I think there's a general aversion to instanceof checks as somehow not "pure" structure, but sometimes anything cleverer would just be over-engineering.

That's not to say that there are zero use cases for function overloading in a dynamic language, but I don't think there are that many.

Regards,
--
Rowan Collins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to