Skip to content

Commit f7b91a2

Browse files
committed
Fix phpstan
1 parent dbe512c commit f7b91a2

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/EventSourcingServiceProvider.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
use Patchlevel\LaravelEventSourcing\Middleware\SubscriptionRebuildAfterFileChangeMiddleware;
100100

101101
use function app;
102+
use function array_filter;
102103
use function array_key_exists;
103104
use function config;
104105
use function config_path;
@@ -184,7 +185,7 @@ private function registerConnection(): void
184185
);
185186
}
186187

187-
/** @var array<string, array{url: string|null, driver: string, database: string, username: string, password: string, host: string, port: int}> $connections */
188+
/** @var array<string, array{url: string|null, driver: string, database?: string|null, username?: string|null, password?: string|null, host?: string|null, port?: int|null}> $connections */
188189
$connections = config('database.connections');
189190

190191
/** @var string $connectionKey */
@@ -211,15 +212,18 @@ private function registerConnection(): void
211212
};
212213

213214
return DriverManager::getConnection(
214-
[
215-
'driver' => $driver,
216-
'dbname' => $connectionParams['database'] ?? null,
217-
'path' => $connectionParams['database'] ?? null,
218-
'user' => $connectionParams['username'] ?? null,
219-
'password' => $connectionParams['password'] ?? null,
220-
'host' => $connectionParams['host'] ?? null,
221-
'port' => $connectionParams['port'] ?? null,
222-
],
215+
array_filter(
216+
[
217+
'driver' => $driver,
218+
'dbname' => $connectionParams['database'] ?? null,
219+
'path' => $connectionParams['database'] ?? null,
220+
'user' => $connectionParams['username'] ?? null,
221+
'password' => $connectionParams['password'] ?? null,
222+
'host' => $connectionParams['host'] ?? null,
223+
'port' => $connectionParams['port'] ?? null,
224+
],
225+
static fn (mixed $value) => $value !== null,
226+
),
223227
);
224228
});
225229
}

0 commit comments

Comments
 (0)