|
34 | 34 | * @throws Throwable |
35 | 35 | */ |
36 | 36 | $InitializeFastestEnvironmentVariables = static function (string $readableChannel): void { |
| 37 | + /** |
| 38 | + * @var array<string, string> $cache |
| 39 | + */ |
37 | 40 | static $cache = []; |
38 | 41 |
|
39 | 42 | 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 | + */ |
41 | 48 | $variables = (new Dotenv())->parse((string)file_get_contents(dirname(__DIR__) . '/.env.test')); |
42 | 49 |
|
| 50 | + /** @var array<string, string> $configuration */ |
43 | 51 | $configuration = JSON::decode((string)file_get_contents($variables['APPLICATION_CONFIG']), true); |
44 | 52 |
|
45 | | - if (!is_array($configuration) || !array_key_exists('DATABASE_URL', $configuration)) { |
| 53 | + if (!array_key_exists('DATABASE_URL', $configuration)) { |
46 | 54 | throw new RuntimeException('Cannot get `DATABASE_URL from specified env file.'); |
47 | 55 | } |
48 | 56 |
|
49 | 57 | $originalDatabaseUrl = $configuration['DATABASE_URL']; |
50 | 58 |
|
51 | | - $databaseName = trim(((array)parse_url((string)$originalDatabaseUrl))['path'] ?? '', '/'); |
| 59 | + $databaseName = trim(((array)parse_url($originalDatabaseUrl))['path'] ?? '', '/'); |
52 | 60 |
|
53 | 61 | // Replace DATABASE_URL variable with proper database name |
54 | 62 | $databaseUrl = str_replace( |
55 | 63 | '/' . $databaseName . '?', |
56 | 64 | '/' . $databaseName . '_' . $readableChannel . '?', |
57 | | - (string)$originalDatabaseUrl |
| 65 | + $originalDatabaseUrl |
58 | 66 | ); |
59 | 67 |
|
60 | 68 | $cache[$readableChannel] = $databaseUrl; |
|
70 | 78 | $InitializeEnvironment = static function (): void { |
71 | 79 | $localPhpEnvFile = dirname(__DIR__) . '/.env.local.php'; |
72 | 80 |
|
73 | | - /** @psalm-suppress MissingFile */ |
| 81 | + /** |
| 82 | + * @psalm-suppress MissingFile |
| 83 | + * @var array<string, string>|null $env |
| 84 | + */ |
74 | 85 | $env = is_readable($localPhpEnvFile) ? include $localPhpEnvFile : null; |
75 | 86 |
|
76 | 87 | // Load cached env vars if the .env.local.php file exists |
|
0 commit comments