Skip to content

Commit 837f24f

Browse files
committed
Static analysis - Fixed type issues from tests/bootstrap.php file
1 parent e531fc3 commit 837f24f

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

tests/bootstrap.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,37 @@
3434
* @throws Throwable
3535
*/
3636
$InitializeFastestEnvironmentVariables = static function (string $readableChannel): void {
37+
/**
38+
* @var array<string, string> $cache
39+
*/
3740
static $cache = [];
3841

3942
if (!array_key_exists($readableChannel, $cache)) {
40-
// Parse current environment file
43+
/**
44+
* Parse current environment file
45+
*
46+
* @var array<string, string> $variables
47+
*/
4148
$variables = (new Dotenv())->parse((string)file_get_contents(dirname(__DIR__) . '/.env.test'));
4249

50+
/**
51+
* @var array<string, string> $configuration
52+
*/
4353
$configuration = JSON::decode((string)file_get_contents($variables['APPLICATION_CONFIG']), true);
4454

45-
if (!is_array($configuration) || !array_key_exists('DATABASE_URL', $configuration)) {
55+
if (!array_key_exists('DATABASE_URL', $configuration)) {
4656
throw new RuntimeException('Cannot get `DATABASE_URL from specified env file.');
4757
}
4858

4959
$originalDatabaseUrl = $configuration['DATABASE_URL'];
5060

51-
$databaseName = trim(((array)parse_url((string)$originalDatabaseUrl))['path'] ?? '', '/');
61+
$databaseName = trim(((array)parse_url($originalDatabaseUrl))['path'] ?? '', '/');
5262

5363
// Replace DATABASE_URL variable with proper database name
5464
$databaseUrl = str_replace(
5565
'/' . $databaseName . '?',
5666
'/' . $databaseName . '_' . $readableChannel . '?',
57-
(string)$originalDatabaseUrl
67+
$originalDatabaseUrl
5868
);
5969

6070
$cache[$readableChannel] = $databaseUrl;
@@ -70,7 +80,10 @@
7080
$InitializeEnvironment = static function (): void {
7181
$localPhpEnvFile = dirname(__DIR__) . '/.env.local.php';
7282

73-
/** @psalm-suppress MissingFile */
83+
/**
84+
* @psalm-suppress MissingFile
85+
* @var array<string, string>|null $env
86+
*/
7487
$env = is_readable($localPhpEnvFile) ? include $localPhpEnvFile : null;
7588

7689
// Load cached env vars if the .env.local.php file exists

0 commit comments

Comments
 (0)