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