From 11c0ad8b0e8188ffb2a299930cb1a0525602f3a8 Mon Sep 17 00:00:00 2001 From: Chris Morrell Date: Wed, 3 Apr 2024 12:37:12 -0400 Subject: [PATCH] Update code style --- .gitignore | 2 +- .php-cs-fixer.dist.php | 3 +++ src/Support/ModularEventServiceProvider.php | 10 +++++----- tests/AutoDiscoveryHelperTest.php | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 6cb2b12..86e8883 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ .php-cs-fixer.cache .composer-history -/vendor +/vendor* /node_modules .env diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 069484f..4ba6fae 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -10,6 +10,7 @@ '@PSR2' => true, 'function_declaration' => [ 'closure_function_spacing' => 'none', + 'closure_fn_spacing' => 'none', ], 'ordered_imports' => [ 'sort_algorithm' => 'alpha', @@ -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') diff --git a/src/Support/ModularEventServiceProvider.php b/src/Support/ModularEventServiceProvider.php index 270a37b..5cfc95d 100644 --- a/src/Support/ModularEventServiceProvider.php +++ b/src/Support/ModularEventServiceProvider.php @@ -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()) ), []); @@ -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(); } diff --git a/tests/AutoDiscoveryHelperTest.php b/tests/AutoDiscoveryHelperTest.php index 51f860b..9ac72e3 100644 --- a/tests/AutoDiscoveryHelperTest.php +++ b/tests/AutoDiscoveryHelperTest.php @@ -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);