Skip to content

Commit

Permalink
Merge branch 'main' into fix/empty-dir-creation
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro authored Apr 3, 2024
2 parents 08c67d4 + c4d2e96 commit a34eecd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.php-cs-fixer.cache
.composer-history

/vendor
/vendor*
/node_modules

.env
Expand Down
3 changes: 3 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'@PSR2' => true,
'function_declaration' => [
'closure_function_spacing' => 'none',
'closure_fn_spacing' => 'none',
],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
Expand Down Expand Up @@ -124,6 +125,8 @@
->exclude('bin')
->exclude('node_modules')
->exclude('vendor')
->exclude('vendor-10') // used for local offline testing
->exclude('vendor-11') // used for local offline testing
->notPath('.phpstorm.meta.php')
->notPath('_ide_helper.php')
->notPath('artisan')
Expand Down
10 changes: 5 additions & 5 deletions src/Support/ModularEventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class ModularEventServiceProvider extends EventServiceProvider
public function discoverEvents()
{
return collect($this->discoverEventsWithin())
->reject(fn ($directory) => ! is_dir($directory))
->reduce(fn ($discovered, $directory) => array_merge_recursive(
->reject(fn($directory) => ! is_dir($directory))
->reduce(fn($discovered, $directory) => array_merge_recursive(
$discovered,
DiscoverEvents::within($directory, $this->eventDiscoveryBasePath())
), []);
Expand All @@ -21,15 +21,15 @@ public function shouldDiscoverEvents()
{
// We'll enable event discovery if it's enabled in the app namespace
return collect($this->app->getProviders(EventServiceProvider::class))
->filter(fn (EventServiceProvider $provider) => str_starts_with(get_class($provider), $this->app->getNamespace()))
->contains(fn (EventServiceProvider $provider) => $provider->shouldDiscoverEvents());
->filter(fn(EventServiceProvider $provider) => str_starts_with(get_class($provider), $this->app->getNamespace()))
->contains(fn(EventServiceProvider $provider) => $provider->shouldDiscoverEvents());
}

protected function discoverEventsWithin()
{
return $this->app->make(AutoDiscoveryHelper::class)
->listenerDirectoryFinder()
->map(fn (SplFileInfo $directory) => $directory->getPathname())
->map(fn(SplFileInfo $directory) => $directory->getPathname())
->values()
->all();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/AutoDiscoveryHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function test_it_finds_event_listeners(): void
]);

$resolved = $this->helper->listenerDirectoryFinder()
->map(fn (SplFileInfo $directory) => str_replace('\\', '/', $directory->getPathname()))
->map(fn(SplFileInfo $directory) => str_replace('\\', '/', $directory->getPathname()))
->all();

$this->assertContains($this->module1->path('src/Listeners'), $resolved);
Expand Down

0 comments on commit a34eecd

Please sign in to comment.