diff --git a/src/Illuminate/Events/Dispatcher.php b/src/Illuminate/Events/Dispatcher.php index 1e193cc889cd..0b35a320c12c 100755 --- a/src/Illuminate/Events/Dispatcher.php +++ b/src/Illuminate/Events/Dispatcher.php @@ -104,7 +104,17 @@ protected function setupWildcardListen($event, $listener) */ public function hasListeners($eventName) { - return isset($this->listeners[$eventName]) || isset($this->wildcards[$eventName]); + $hasWildcard = function ($eventName) { + foreach ($this->wildcards as $key => $listeners) { + if (Str::is($key, $eventName)) { + return true; + } + } + + return false; + }; + + return isset($this->listeners[$eventName]) || isset($this->wildcards[$eventName]) || $hasWildcard($eventName); } /** diff --git a/tests/Events/EventsDispatcherTest.php b/tests/Events/EventsDispatcherTest.php index 55b55428732a..548f0f9f55a3 100755 --- a/tests/Events/EventsDispatcherTest.php +++ b/tests/Events/EventsDispatcherTest.php @@ -192,6 +192,7 @@ public function testWildcardListenersCanBeFound() // }); $this->assertTrue($d->hasListeners('foo.*')); + $this->assertTrue($d->hasListeners('foo.bar')); } public function testEventPassedFirstToWildcards()