Skip to content

Commit 19f30e2

Browse files
committed
Deprecating "false" as default value of "strict_variable" under Twig configuration
1 parent 1df45e4 commit 19f30e2

File tree

18 files changed

+69
-22
lines changed

18 files changed

+69
-22
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
imports:
2-
- { resource: ./../config/framework.yml }
2+
- { resource: ./../config/default.yml }
33

44
security:
55
encoders:

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/custom_handlers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
imports:
2-
- { resource: ./../config/framework.yml }
2+
- { resource: ./../config/default.yml }
33

44
security:
55
encoders:

src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode)
127127
->scalarNode('cache')->defaultValue('%kernel.cache_dir%/twig')->end()
128128
->scalarNode('charset')->defaultValue('%kernel.charset%')->end()
129129
->booleanNode('debug')->defaultValue('%kernel.debug%')->end()
130-
->booleanNode('strict_variables')->end()
130+
->booleanNode('strict_variables')
131+
->defaultValue(function () {
132+
@trigger_error('Relying on the default value ("false") of the "twig.strict_variables" configuration option is deprecated since Symfony 4.1. You should use "%kernel.debug%" explicitly instead, which will be the new default in 5.0.', E_USER_DEPRECATED);
133+
134+
return false;
135+
})
136+
->end()
131137
->scalarNode('auto_reload')->end()
132138
->integerNode('optimizations')->min(-1)->end()
133139
->scalarNode('default_path')

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class ConfigurationTest extends TestCase
2020
public function testDoNoDuplicateDefaultFormResources()
2121
{
2222
$input = array(
23+
'strict_variables' => false, // to be removed in 5.0 relying on default
2324
'form_themes' => array('form_div_layout.html.twig'),
2425
);
2526

@@ -28,4 +29,16 @@ public function testDoNoDuplicateDefaultFormResources()
2829

2930
$this->assertEquals(array('form_div_layout.html.twig'), $config['form_themes']);
3031
}
32+
33+
/**
34+
* @group legacy
35+
* @expectedDeprecation Relying on the default value ("false") of the "twig.strict_variables" configuration option is deprecated since Symfony 4.1. You should use "%kernel.debug%" explicitly instead, which will be the new default in 5.0.
36+
*/
37+
public function testGetStrictVariablesDefaultFalse()
38+
{
39+
$processor = new Processor();
40+
$config = $processor->processConfiguration(new Configuration(), array(array()));
41+
42+
$this->assertFalse($config['strict_variables']);
43+
}
3144
}

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
$container->loadFromExtension('twig', array(
44
'autoescape_service' => 'my_project.some_bundle.template_escaping_guesser',
55
'autoescape_service_method' => 'guess',
6+
'strict_variables' => false, // to be removed in 5.0 relying on default
67
));
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<?php
22

3-
$container->loadFromExtension('twig', array());
3+
$container->loadFromExtension('twig', array(
4+
'strict_variables' => false, // to be removed in 5.0 relying on default
5+
));
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

33
$container->loadFromExtension('twig', array(
4-
'paths' => array(
5-
'namespaced_path3' => 'namespace3',
6-
),
4+
'paths' => array(
5+
'namespaced_path3' => 'namespace3',
6+
),
7+
'strict_variables' => false, // to be removed in 5.0 relying on default
78
));

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
'decimal_point' => ',',
1212
'thousands_separator' => '.',
1313
),
14+
'strict_variables' => false, // to be removed in 5.0 relying on default
1415
));

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
77
http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd">
88

9-
<twig:config autoescape-service="my_project.some_bundle.template_escaping_guesser" autoescape-service-method="guess" />
9+
<twig:config autoescape-service="my_project.some_bundle.template_escaping_guesser" autoescape-service-method="guess" strict-variables="false" />
1010
</container>

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
77
http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd">
88

9-
<twig:config />
9+
<twig:config strict-variables="false" />
1010
</container>

0 commit comments

Comments
 (0)