Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit308e3a3

Browse files
committed
properly handle SYMFONY_DOTENV_VARS being the empty string
1 parent8d06a8a commit308e3a3

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

‎src/Symfony/Component/Dotenv/Command/DebugCommand.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8282

8383
privatefunctiongetVariables(array$envFiles):array
8484
{
85-
$vars =explode(',',$_SERVER['SYMFONY_DOTENV_VARS'] ??'');
85+
$dotenvVars =$_SERVER['SYMFONY_DOTENV_VARS'] ??'';
86+
87+
if ('' ===$dotenvVars) {
88+
return [];
89+
}
90+
91+
$vars =explode(',',$dotenvVars);
8692
sort($vars);
8793

8894
$output = [];

‎src/Symfony/Component/Dotenv/Tests/Command/DebugCommandTest.php‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class DebugCommandTest extends TestCase
2525
*/
2626
publicfunctiontestErrorOnUninitializedDotenv()
2727
{
28+
unset($_SERVER['SYMFONY_DOTENV_VARS']);
29+
2830
$command =newDebugCommand('dev',__DIR__.'/Fixtures/Scenario1');
2931
$command->setHelperSet(newHelperSet([newFormatterHelper()]));
3032
$tester =newCommandTester($command);
@@ -34,6 +36,27 @@ public function testErrorOnUninitializedDotenv()
3436
$this->assertStringContainsString('[ERROR] Dotenv component is not initialized',$output);
3537
}
3638

39+
publicfunctiontestEmptyDotEnvVarsList()
40+
{
41+
$_SERVER['SYMFONY_DOTENV_VARS'] ='';
42+
43+
$command =newDebugCommand('dev',__DIR__.'/Fixtures/Scenario1');
44+
$command->setHelperSet(newHelperSet([newFormatterHelper()]));
45+
$tester =newCommandTester($command);
46+
$tester->execute([]);
47+
$output =$tester->getDisplay();
48+
49+
$expectedFormat = <<<'OUTPUT'
50+
%a
51+
---------- ------- ------------ ------%S
52+
Variable Value .env.local .env%S
53+
---------- ------- ------------ ------%S
54+
%a
55+
OUTPUT;
56+
57+
$this->assertStringMatchesFormat($expectedFormat,$output);
58+
}
59+
3760
publicfunctiontestScenario1InDevEnv()
3861
{
3962
$output =$this->executeCommand(__DIR__.'/Fixtures/Scenario1','dev');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp