Skip to content

Commit

Permalink
[6.x] Prevent event autodiscovery from crashing when trying to instan…
Browse files Browse the repository at this point in the history
…tiate files without classes (#29895)

* Make sure event autodiscovery doesn't fail when trying to instantiate files that are not classes

* Moving exception to comply with styles
  • Loading branch information
tomasruud authored and taylorotwell committed Sep 6, 2019
1 parent 0fca254 commit aa2e7b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Illuminate/Foundation/Events/DiscoverEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use SplFileInfo;
use ReflectionClass;
use ReflectionMethod;
use ReflectionException;
use Illuminate\Support\Str;
use Symfony\Component\Finder\Finder;

Expand Down Expand Up @@ -38,9 +39,13 @@ protected static function getListenerEvents($listeners, $basePath)
$listenerEvents = [];

foreach ($listeners as $listener) {
$listener = new ReflectionClass(
static::classFromFile($listener, $basePath)
);
try {
$listener = new ReflectionClass(
static::classFromFile($listener, $basePath)
);
} catch (ReflectionException $e) {
continue;
}

if (! $listener->isInstantiable()) {
continue;
Expand Down
Empty file.

0 comments on commit aa2e7b6

Please sign in to comment.