Skip to content

Commit 0281a21

Browse files
authored
Merge pull request #2536 from tarlepp/sa/fixes-to-phpunit-bootstrap
Static analysis - Fixed type issues from `tests/bootstrap.php` file
2 parents 7b4e1b1 + cd1e412 commit 0281a21

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tests/bootstrap.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,35 @@
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+
/** @var array<string, string> $configuration */
4351
$configuration = JSON::decode((string)file_get_contents($variables['APPLICATION_CONFIG']), true);
4452

45-
if (!is_array($configuration) || !array_key_exists('DATABASE_URL', $configuration)) {
53+
if (!array_key_exists('DATABASE_URL', $configuration)) {
4654
throw new RuntimeException('Cannot get `DATABASE_URL from specified env file.');
4755
}
4856

4957
$originalDatabaseUrl = $configuration['DATABASE_URL'];
5058

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

5361
// Replace DATABASE_URL variable with proper database name
5462
$databaseUrl = str_replace(
5563
'/' . $databaseName . '?',
5664
'/' . $databaseName . '_' . $readableChannel . '?',
57-
(string)$originalDatabaseUrl
65+
$originalDatabaseUrl
5866
);
5967

6068
$cache[$readableChannel] = $databaseUrl;
@@ -70,7 +78,10 @@
7078
$InitializeEnvironment = static function (): void {
7179
$localPhpEnvFile = dirname(__DIR__) . '/.env.local.php';
7280

73-
/** @psalm-suppress MissingFile */
81+
/**
82+
* @psalm-suppress MissingFile
83+
* @var array<string, string>|null $env
84+
*/
7485
$env = is_readable($localPhpEnvFile) ? include $localPhpEnvFile : null;
7586

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

0 commit comments

Comments
 (0)