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

Appearance settings

Commit e50aa54

Browse filesBrowse files
committed
show overridden vars too
1 parent a4dc5f7 commit e50aa54
Copy full SHA for e50aa54

File tree

1 file changed

+29
-13
lines changed
Filter options

1 file changed

+29
-13
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dotenv/Command/DebugCommand.php
+29-13Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,42 @@ private function getVariables(array $envFiles): array
8888
return [];
8989
}
9090

91-
$vars = explode(',', $dotenvVars);
92-
sort($vars);
91+
$dotenvVars = explode(',', $dotenvVars);
92+
93+
$AllDotenvVars = $this->getAllVarsFromEnvFiles($envFiles);
9394

94-
$output = [];
95-
$fileValues = [];
96-
foreach ($vars as $var) {
95+
$variables = [];
96+
foreach ($AllDotenvVars as $var) {
9797
$realValue = $_SERVER[$var];
98-
$varDetails = [$var, $realValue];
98+
$details = [$var, $realValue];
9999
foreach ($envFiles as $envFile) {
100-
$values = $fileValues[$envFile] ?? $fileValues[$envFile] = $this->loadValues($envFile);
101-
102-
$varString = $values[$var] ?? '<fg=yellow>n/a</>';
103-
$shortenedVar = $this->getHelper('formatter')->truncate($varString, 30);
104-
$varDetails[] = $varString === $realValue ? '<fg=green>'.$shortenedVar.'</>' : $shortenedVar;
100+
$envFileValues = $this->loadValues($envFile);
101+
if (\array_key_exists($var, $envFileValues)) {
102+
$shortenedVar = $this->getHelper('formatter')->truncate($envFileValues[$var], 30);
103+
$shortenedVar = \in_array($var, $dotenvVars) && $realValue === $envFileValues[$var] ? '<fg=green>'.$shortenedVar.'</>' : '<fg=red>'.$shortenedVar.'</>';
104+
} else {
105+
$shortenedVar = '<fg=yellow>n/a</>';
106+
}
107+
$details[] = $shortenedVar;
105108
}
106109

107-
$output[] = $varDetails;
110+
$variables[] = $details;
111+
}
112+
113+
return $variables;
114+
}
115+
116+
private function getAllVarsFromEnvFiles(array $files): array
117+
{
118+
$vars = [];
119+
foreach ($files as $file) {
120+
$vars = array_merge($this->loadValues($file), $vars);
108121
}
109122

110-
return $output;
123+
$vars = array_keys($vars);
124+
sort($vars);
125+
126+
return $vars;
111127
}
112128

113129
private function getEnvFiles(): array

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.