8000 bug #22976 [DependencyInjection] Use more clear message when unused e… · symfony/symfony@12f5636 · GitHub
[go: up one dir, main page]

Skip to content

Commit 12f5636

Browse files
committed
bug #22976 [DependencyInjection] Use more clear message when unused environment variables detected (voronkovich)
This PR was squashed before being merged into the 3.2 branch (closes #22976). Discussion ---------- [DependencyInjection] Use more clear message when unused environment variables detected | Q | A | ------------- | --- | Branch? |3.2 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22955 | License | MIT Old error message: ``` Incompatible use of dynamic environment variables "DATABASE_URL", "MAILER_URL" found in parameters. ``` New error message: ``` Environment variables "DATABASE_URL", "MAILER_URL" are never used. Please, check your container's configuration. ``` Commits ------- 6dbdb1b [DependencyInjection] Use more clear message when unused environment variables detected
2 parents 7078cdf + 6dbdb1b commit 12f5636

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function dump(array $options = array())
166166
}
167167
}
168168
if ($unusedEnvs) {
169-
throw new EnvParameterException($unusedEnvs);
169+
throw new EnvParameterException($unusedEnvs, null, 'Environment variables "%s" are never used. Please, check your container\'s configuration.');
170170
}
171171

172172
return $code;

src/Symfony/Component/DependencyInjection/Exception/EnvParameterException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
class EnvParameterException extends InvalidArgumentException
2020
{
21-
public function __construct(array $usedEnvs, \Exception $previous = null)
21+
public function __construct(array $envs, \Exception $previous = null, $message = 'Incompatible use of dynamic environment variables "%s" found in parameters.')
2222
{
23-
parent::__construct(sprintf('Incompatible use of dynamic environment variables "%s" found in parameters.', implode('", "', $usedEnvs)), 0, $previous);
23+
parent::__construct(sprintf($message, implode('", "', $envs)), 0, $previous);
2424
}
2525
}

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public function testEnvParameter()
302302

303303
/**
304304
* @expectedException \Symfony\Component\DependencyInjection\Exception\EnvParameterException
305-
* @expectedExceptionMessage Incompatible use of dynamic environment variables "FOO" found in parameters.
305+
* @expectedExceptionMessage Environment variables "FOO" are never used. Please, check your container's configuration.
306306
*/
307307
public function testUnusedEnvParameter()
308308
{

0 commit comments

Comments
 (0)
0