8000 [Dotenv] Check required dotenvs by pizzaminded · Pull Request #32729 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Dotenv] Check required dotenvs #32729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Dotenv] applied coding standards patch
  • Loading branch information
pizzaminded committed Jul 24, 2019
commit e199b3cf7531302af6f299eed33dc8a349bfb79c
5 changes: 2 additions & 3 deletions src/Symfony/Component/Dotenv/Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,14 @@ public function checkRequired(array $variables): void
$missingKeys = [];

foreach ($variables as $variable) {
if(!isset($_ENV[$variable])) {
if (!isset($_ENV[$variable])) {
$missingKeys[] = $variable;
}
}

if(count($missingKeys) > 0) {
if (\count($missingKeys) > 0) {
throw new \RuntimeException(sprintf('Following environment variables are missing: %s', implode(', ', $missingKeys)));
}

}

private function lexVarname()
Expand Down
6 changes: 2 additions & 4 deletions src/Symfony/Component/Dotenv/Tests/DotenvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ public function testSomeEnvVarsAreMissing()
$dotenv->populate(['FOO' => 'foo', 'BAR' => 'bar']);

$dotenv->checkRequired(['FOO', 'BAR', 'BAZ']);

}

/**
Expand All @@ -467,14 +466,13 @@ public function testRequiredEnvsExceptionsContainsAllMissingVariableNames()
$dotenv->checkRequired(['FOO', 'BAR', 'BAZ', 'FOOBAR']);
}


/**
* When all of required variables are set, method should not throw anything
* When all of required variables are set, method should not throw anything.
*
* @doesNotPerformAssertions
*/
public function testNothingWillHappenWhenAllEnvVarsAreSet()
{

$dotenv = new Dotenv();
$dotenv->populate(['FOO' => 'foo', 'BAR' => 'bar']);

Expand Down
0