Skip to content

[DI] Remove hasty verification of unused env variables #22726

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 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,8 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs
/**
* Get statistics about env usage.
*
* @deprecated unused and must be removed in some next release
Copy link
Contributor

@Taluu Taluu May 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Symfony 4.0, deprecated since 3.4

*
* @return int[] The number of time each env vars has been resolved
*/
public function getEnvCounters()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should add a @trigger_error() call here

Expand Down
10 changes: 0 additions & 10 deletions src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,6 @@ public function dump(array $options = array())
;
$this->targetDirRegex = null;

$unusedEnvs = array();
foreach ($this->container->getEnvCounters() as $env => $use) {
if (!$use) {
$unusedEnvs[] = $env;
}
}
if ($unusedEnvs) {
throw new EnvParameterException($unusedEnvs);
}

return $code;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,6 @@ public function testEnvParameter()
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services26.php', $dumper->dump(), '->dump() dumps inline definitions which reference service_container');
}

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\EnvParameterException
* @expectedExceptionMessage Incompatible use of dynamic environment variables "FOO" found in parameters.
*/
public function testUnusedEnvParameter()
{
$container = new ContainerBuilder();
$container->getParameter('env(FOO)');
$container->compile();
$dumper = new PhpDumper($container);
$dumper->dump();
}

public function testInlinedDefinitionReferencingServiceContainer()
{
$container = new ContainerBuilder();
Expand Down