Merge branch '3.4' into 4.1
* 3.4: account for the short array syntax in Twig
This commit is contained in:
commit
c325155e10
@ -44,7 +44,7 @@ class DumpNode extends Node
|
|||||||
if (!$this->hasNode('values')) {
|
if (!$this->hasNode('values')) {
|
||||||
// remove embedded templates (macros) from the context
|
// remove embedded templates (macros) from the context
|
||||||
$compiler
|
$compiler
|
||||||
->write(sprintf('$%svars = array();'."\n", $this->varPrefix))
|
->write(sprintf('$%svars = [];'."\n", $this->varPrefix))
|
||||||
->write(sprintf('foreach ($context as $%1$skey => $%1$sval) {'."\n", $this->varPrefix))
|
->write(sprintf('foreach ($context as $%1$skey => $%1$sval) {'."\n", $this->varPrefix))
|
||||||
->indent()
|
->indent()
|
||||||
->write(sprintf('if (!$%sval instanceof \Twig\Template) {'."\n", $this->varPrefix))
|
->write(sprintf('if (!$%sval instanceof \Twig\Template) {'."\n", $this->varPrefix))
|
||||||
@ -65,7 +65,7 @@ class DumpNode extends Node
|
|||||||
} else {
|
} else {
|
||||||
$compiler
|
$compiler
|
||||||
->addDebugInfo($this)
|
->addDebugInfo($this)
|
||||||
->write('\Symfony\Component\VarDumper\VarDumper::dump(array('."\n")
|
->write('\Symfony\Component\VarDumper\VarDumper::dump(['."\n")
|
||||||
->indent();
|
->indent();
|
||||||
foreach ($values as $node) {
|
foreach ($values as $node) {
|
||||||
$compiler->write('');
|
$compiler->write('');
|
||||||
@ -80,7 +80,7 @@ class DumpNode extends Node
|
|||||||
}
|
}
|
||||||
$compiler
|
$compiler
|
||||||
->outdent()
|
->outdent()
|
||||||
->write("));\n");
|
->write("]);\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
$compiler
|
$compiler
|
||||||
|
@ -100,7 +100,7 @@ class SearchAndRenderBlockNode extends FunctionExpression
|
|||||||
// If not, add it to the array at runtime.
|
// If not, add it to the array at runtime.
|
||||||
$compiler->raw('(twig_test_empty($_label_ = ');
|
$compiler->raw('(twig_test_empty($_label_ = ');
|
||||||
$compiler->subcompile($label);
|
$compiler->subcompile($label);
|
||||||
$compiler->raw(') ? array() : array("label" => $_label_))');
|
$compiler->raw(') ? [] : ["label" => $_label_])');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class DumpNodeTest extends TestCase
|
|||||||
|
|
||||||
$expected = <<<'EOTXT'
|
$expected = <<<'EOTXT'
|
||||||
if ($this->env->isDebug()) {
|
if ($this->env->isDebug()) {
|
||||||
$barvars = array();
|
$barvars = [];
|
||||||
foreach ($context as $barkey => $barval) {
|
foreach ($context as $barkey => $barval) {
|
||||||
if (!$barval instanceof \Twig\Template) {
|
if (!$barval instanceof \Twig\Template) {
|
||||||
$barvars[$barkey] = $barval;
|
$barvars[$barkey] = $barval;
|
||||||
@ -53,7 +53,7 @@ EOTXT;
|
|||||||
|
|
||||||
$expected = <<<'EOTXT'
|
$expected = <<<'EOTXT'
|
||||||
if ($this->env->isDebug()) {
|
if ($this->env->isDebug()) {
|
||||||
$barvars = array();
|
$barvars = [];
|
||||||
foreach ($context as $barkey => $barval) {
|
foreach ($context as $barkey => $barval) {
|
||||||
if (!$barval instanceof \Twig\Template) {
|
if (!$barval instanceof \Twig\Template) {
|
||||||
$barvars[$barkey] = $barval;
|
$barvars[$barkey] = $barval;
|
||||||
@ -105,10 +105,10 @@ EOTXT;
|
|||||||
$expected = <<<'EOTXT'
|
$expected = <<<'EOTXT'
|
||||||
if ($this->env->isDebug()) {
|
if ($this->env->isDebug()) {
|
||||||
// line 7
|
// line 7
|
||||||
\Symfony\Component\VarDumper\VarDumper::dump(array(
|
\Symfony\Component\VarDumper\VarDumper::dump([
|
||||||
"foo" => %foo%,
|
"foo" => %foo%,
|
||||||
"bar" => %bar%,
|
"bar" => %bar%,
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOTXT;
|
EOTXT;
|
||||||
|
@ -61,7 +61,7 @@ class FormThemeTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"), true);',
|
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [0 => "tpl1", 1 => "tpl2"], true);',
|
||||||
$this->getVariableGetter('form')
|
$this->getVariableGetter('form')
|
||||||
),
|
),
|
||||||
trim($compiler->compile($node)->getSource())
|
trim($compiler->compile($node)->getSource())
|
||||||
@ -71,7 +71,7 @@ class FormThemeTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, array(0 => "tpl1", 1 => "tpl2"), false);',
|
'$this->env->getRuntime("Symfony\\\\Component\\\\Form\\\\FormRenderer")->setTheme(%s, [0 => "tpl1", 1 => "tpl2"], false);',
|
||||||
$this->getVariableGetter('form')
|
$this->getVariableGetter('form')
|
||||||
),
|
),
|
||||||
trim($compiler->compile($node)->getSource())
|
trim($compiler->compile($node)->getSource())
|
||||||
|
@ -58,7 +58,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'widget\', array("foo" => "bar"))',
|
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'widget\', ["foo" => "bar"])',
|
||||||
$this->getVariableGetter('form')
|
$this->getVariableGetter('form')
|
||||||
),
|
),
|
||||||
trim($compiler->compile($node)->getSource())
|
trim($compiler->compile($node)->getSource())
|
||||||
@ -78,7 +78,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("label" => "my label"))',
|
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["label" => "my label"])',
|
||||||
$this->getVariableGetter('form')
|
$this->getVariableGetter('form')
|
||||||
),
|
),
|
||||||
trim($compiler->compile($node)->getSource())
|
trim($compiler->compile($node)->getSource())
|
||||||
@ -168,7 +168,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
// https://github.com/symfony/symfony/issues/5029
|
// https://github.com/symfony/symfony/issues/5029
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("foo" => "bar"))',
|
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar"])',
|
||||||
$this->getVariableGetter('form')
|
$this->getVariableGetter('form')
|
||||||
),
|
),
|
||||||
trim($compiler->compile($node)->getSource())
|
trim($compiler->compile($node)->getSource())
|
||||||
@ -194,7 +194,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', array("foo" => "bar", "label" => "value in argument"))',
|
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar", "label" => "value in argument"])',
|
||||||
$this->getVariableGetter('form')
|
$this->getVariableGetter('form')
|
||||||
),
|
),
|
||||||
trim($compiler->compile($node)->getSource())
|
trim($compiler->compile($node)->getSource())
|
||||||
@ -225,7 +225,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
// https://github.com/symfony/symfony/issues/5029
|
// https://github.com/symfony/symfony/issues/5029
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? array() : array("label" => $_label_)))',
|
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))',
|
||||||
$this->getVariableGetter('form')
|
$this->getVariableGetter('form')
|
||||||
),
|
),
|
||||||
trim($compiler->compile($node)->getSource())
|
trim($compiler->compile($node)->getSource())
|
||||||
@ -262,7 +262,7 @@ class SearchAndRenderBlockNodeTest extends TestCase
|
|||||||
// https://github.com/symfony/symfony/issues/5029
|
// https://github.com/symfony/symfony/issues/5029
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
'$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_)))',
|
'$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_]))',
|
||||||
$this->getVariableGetter('form')
|
$this->getVariableGetter('form')
|
||||||
),
|
),
|
||||||
trim($compiler->compile($node)->getSource())
|
trim($compiler->compile($node)->getSource())
|
||||||
|
@ -34,7 +34,7 @@ class TransNodeTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
sprintf(
|
sprintf(
|
||||||
'echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->getTranslator()->trans("trans %%var%%", array_merge(array("%%var%%" => %s), %s), "messages");',
|
'echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->getTranslator()->trans("trans %%var%%", array_merge(["%%var%%" => %s], %s), "messages");',
|
||||||
$this->getVariableGetterWithoutStrictCheck('var'),
|
$this->getVariableGetterWithoutStrictCheck('var'),
|
||||||
$this->getVariableGetterWithStrictCheck('foo')
|
$this->getVariableGetterWithStrictCheck('foo')
|
||||||
),
|
),
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3",
|
"php": "^7.1.3",
|
||||||
"twig/twig": "^1.35|^2.4.4"
|
"twig/twig": "^1.36.1|^2.6.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/asset": "~3.4|~4.0",
|
"symfony/asset": "~3.4|~4.0",
|
||||||
|
Reference in New Issue
Block a user