8000 Deprecate the special SYMFONY__ environment variables by javiereguiluz · Pull Request #21889 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Deprecate the special SYMFONY__ environment variables #21889

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 10 commits into from
Next Next commit
Deprecate the special SYMFONY__ environment variables
  • Loading branch information
javiereguiluz committed Mar 19, 2017
commit 2b8b6c7ffcd23a42d796415981e788d871df637c
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ protected function getEnvParameters()
$parameters = array();
foreach ($_SERVER as $key => $value) {
if (0 === strpos($key, 'SYMFONY__')) {
@trigger_error(sprintf('The support of special environment variables that start with SYMFONY__ (such as "%s") is deprecated as of 3.3 and will be removed in 4.0. Use the %env()% syntax instead to get the value of environment variables in configuration files.', $key), E_USER_DEPRECATED);
$parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value;
Copy link
Member
@chalasr chalasr Mar 14, 2017

Choose a reason for hiding this comment

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

%env()% should be %%env()%%

}
}
Expand Down
16 changes: 16 additions & 0 deletions src/Symfony/Component/HttpKernel/Tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,22 @@ public function testKernelRootDirNameStartingWithANumber()
$this->assertEquals('_123', $kernel->getName());
}

/**
* @group legacy
* @expectedDeprecation The support of special environment variables that start with SYMFONY__ (such as "SYMFONY__FOO__BAR") is deprecated as of 3.3 and will be removed in 4.0. Use the %env()% syntax instead to get the value of environment variables in configuration files.
Copy link
Member

Choose a reason for hiding this comment

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

The use of %env()% makes the assertion fails due to the use of assertStringMatchesFormat. For now I didn't find better than replacing %env()% by %s in the expected deprecation to solve this issue

Copy link
Member

Choose a reason for hiding this comment

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

%c is a bit better :)

*/
public function testSymfonyEnvironmentVariables()
{
$_SERVER['SYMFONY__FOO__BAR'] = 'baz';

$kernel = $this->getKernel();
$method = new \ReflectionMethod($kernel, 'getEnvParameters');
$method->setAccessible(true);

$envParameters = $method->invoke($kernel);
$this->assertSame('baz', $envParameters['foo.bar']);
}

/**
* Returns a mock for the BundleInterface.
*
Expand Down
0