8000 Merge branch '4.1' into 4.2 · symfony/symfony@2dddea4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2dddea4

Browse files
committed
Merge branch '4.1' into 4.2
* 4.1: account for the short array syntax in Twig
2 parents 2c9a371 + c325155 commit 2dddea4

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

src/Symfony/Bridge/Twig/Node/DumpNode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function compile(Compiler $compiler)
4444
if (!$this->hasNode('values')) {
4545
// remove embedded templates (macros) from the context
4646
$compiler
47-
->write(sprintf('$%svars = array();'."\n", $this->varPrefix))
47+
->write(sprintf('$%svars = [];'."\n", $this->varPrefix))
4848
->write(sprintf('foreach ($context as $%1$skey => $%1$sval) {'."\n", $this->varPrefix))
4949
->indent()
5050
->write(sprintf('if (!$%sval instanceof \Twig\Template) {'."\n", $this->varPrefix))
@@ -65,7 +65,7 @@ public function compile(Compiler $compiler)
6565
} else {
6666
$compiler
6767
->addDebugInfo($this)
68-
->write('\Symfony\Component\VarDumper\VarDumper::dump(array('."\n")
68+
->write('\Symfony\Component\VarDumper\VarDumper::dump(['."\n")
6969
->indent();
7070
foreach ($values as $node) {
7171
$compiler->write('');
@@ -80,7 +80,7 @@ public function compile(Compiler $compiler)
8080
}
8181
$compiler
8282
->outdent()
83-
->write("));\n");
83+
->write("]);\n");
8484
}
8585

8686
$compiler

src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function compile(Compiler $compiler)
100100
// If not, add it to the array at runtime.
101101
$compiler->raw('(twig_test_empty($_label_ = ');
102102
$compiler->subcompile($label);
103-
$compiler->raw(') ? array() : array("label" => $_label_))');
103+
$compiler->raw(') ? [] : ["label" => $_label_])');
104104
}
105105
}
106106
}

src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testNoVar()
2929

3030
$expected = <<<'EOTXT'
3131
if ($this->env->isDebug()) {
32-
$barvars = array();
32+
$barvars = [];
3333
foreach ($context as $barkey => $barval) {
3434
if (!$barval instanceof \Twig\Template) {
3535
$barvars[$barkey] = $barval;
@@ -53,7 +53,7 @@ public function testIndented()
5353

5454
$expected = <<<'EOTXT'
5555
if ($this->env->isDebug()) {
56-
$barvars = array();
56+
$barvars = [];
5757
foreach ($context as $barkey => $barval) {
5858
if (!$barval instanceof \Twig\Template) {
5959
$barvars[$barkey] = $barval;
@@ -105,10 +105,10 @@ public function testMultiVars()
105105
$expected = <<<'EOTXT'
106106
if ($this->env->isDebug()) {
107107
// line 7
108-
\Symfony\Component\VarDumper\VarDumper::dump(array(
108+
\Symfony\Component\VarDumper\VarDumper::dump([
109109
"foo" => %foo%,
110110
"bar" => %bar%,
111-
));
111+
]);
112112
}
113113

114114
EOTXT;

src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php

Lines changed: 2 additions & 2 deletions
< 57AE div class="border position-relative rounded-bottom-2">
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testCompile()
6161

6262
$this->assertEquals(
6363
sprintf(
64-
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"), true);',
64+
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [0 => "tpl1", 1 => "tpl2"], true);',
6565
$this->getVariableGetter('form')
6666
),
6767
trim($compiler->compile($node)->getSource())
@@ -71,7 +71,7 @@ public function testCompile()
7171

7272
$this->assertEquals(
7373
sprintf(
74-
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"), false);',
74+
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [0 => "tpl1", 1 => "tpl2"], false);',
7575
$this->getVariableGetter('form')
7676
),
7777
trim($compiler->compile($node)->getSource())

src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testCompileWidgetWithVariables()
5858

5959
$this->assertEquals(
6060
sprintf(
61-
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'widget\', array("foo" => "bar"))',
61+
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'widget\', ["foo" => "bar"])',
6262
$this->getVariableGetter('form')
6363
),
6464
trim($compiler->compile($node)->getSource())
@@ -78,7 +78,7 @@ public function testCompileLabelWithLabel()
7878

7979
$this->assertEquals(
8080
sprintf(
81-
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("label" => "my label"))',
81+
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["label" => "my label"])',
8282
$this->getVariableGetter('form')
8383
),
8484
trim($compiler->compile($node)->getSource())
@@ -168,7 +168,7 @@ public function testCompileLabelWithAttributes()
168168
// https://github.com/symfony/symfony/issues/5029
169169
$this->assertEquals(
170170
sprintf(
171-
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("foo" => "bar"))',
171+
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar"])',
172172
$this->getVariableGetter('form')
173173
),
174174
trim($compiler->compile($node)->getSource())
@@ -194,7 +194,7 @@ public function testCompileLabelWithLabelAndAttributes()
194194

195195
$this->assertEquals(
196196
sprintf(
197-
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("foo" => "bar", "label" => "value in argument"))',
197+
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar", "label" => "value in argument"])',
198198
$this->getVariableGetter('form')
199199
),
200200
trim($compiler->compile($node)->getSource())
@@ -225,7 +225,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
225225
// https://github.com/symfony/symfony/issues/5029
226226
$this->assertEquals(
227227
sprintf(
228-
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? array() : array("label" => $_label_)))',
228+
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))',
229229
$this->getVariableGetter('form')
230230
),
231231
trim($compiler->compile($node)->getSource())
@@ -262,7 +262,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
262262
// https://github.com/symfony/symfony/issues/5029
263263
$this->assertEquals(
264264
sprintf(
265-
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("foo" => "bar", "label" => "value in attributes") + (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? array() : array("label" => $_label_)))',
265+
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar", "label" => "value in attributes"] + (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))',
266266
$this->getVariableGetter('form')
267267
),
268268
trim($compiler->compile($node)->getSource())

src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testCompileStrict()
3434

3535
$this->assertEquals(
3636
sprintf(
37-
'echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans("trans %%var%%", array_merge(array("%%var%%" => %s), %s), "messages");',
37+
'echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans("trans %%var%%", array_merge(["%%var%%" => %s], %s), "messages");',
3838
$this->getVariableGetterWithoutStrictCheck('var'),
3939
$this->getVariableGetterWithStrictCheck('foo')
4040
),

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": "^7.1.3",
2020
"symfony/contracts": "^1.0.2",
21-
"twig/twig": "^1.35|^2.4.4"
21+
"twig/twig": "^1.36.1|^2.6.1"
2222
},
2323
"require-dev": {
2424
"symfony/asset": "~3.4|~4.0",

0 commit comments

Comments
 (0)
0