Augmentation vers version 3.3.0

This commit is contained in:
Gauvain Boiché
2020-03-31 15:31:03 +02:00
parent d926806907
commit a1864c0414
2618 changed files with 406015 additions and 31377 deletions

View File

@@ -35,12 +35,17 @@ class FormThemeTokenParser extends AbstractTokenParser
$stream = $this->parser->getStream();
$form = $this->parser->getExpressionParser()->parseExpression();
$only = false;
if ($this->parser->getStream()->test(Token::NAME_TYPE, 'with')) {
$this->parser->getStream()->next();
$resources = $this->parser->getExpressionParser()->parseExpression();
if ($this->parser->getStream()->nextIf(Token::NAME_TYPE, 'only')) {
$only = true;
}
} else {
$resources = new ArrayExpression(array(), $stream->getCurrent()->getLine());
$resources = new ArrayExpression([], $stream->getCurrent()->getLine());
do {
$resources->addElement($this->parser->getExpressionParser()->parseExpression());
} while (!$stream->test(Token::BLOCK_END_TYPE));
@@ -48,7 +53,7 @@ class FormThemeTokenParser extends AbstractTokenParser
$stream->expect(Token::BLOCK_END_TYPE);
return new FormThemeNode($form, $resources, $lineno, $this->getTag());
return new FormThemeNode($form, $resources, $lineno, $this->getTag(), $only);
}
/**

View File

@@ -41,7 +41,7 @@ class StopwatchTokenParser extends AbstractTokenParser
$stream->expect(Token::BLOCK_END_TYPE);
// {% endstopwatch %}
$body = $this->parser->subparse(array($this, 'decideStopwatchEnd'), true);
$body = $this->parser->subparse([$this, 'decideStopwatchEnd'], true);
$stream->expect(Token::BLOCK_END_TYPE);
if ($this->stopwatchIsAvailable) {

View File

@@ -15,7 +15,6 @@ use Symfony\Bridge\Twig\Node\TransNode;
use Twig\Error\SyntaxError;
use Twig\Node\Expression\AbstractExpression;
use Twig\Node\Expression\ArrayExpression;
use Twig\Node\Node;
use Twig\Node\TextNode;
use Twig\Token;
@@ -27,18 +26,14 @@ use Twig\Token;
class TransChoiceTokenParser extends TransTokenParser
{
/**
* Parses a token and returns a node.
*
* @return Node
*
* @throws SyntaxError
* {@inheritdoc}
*/
public function parse(Token $token)
{
$lineno = $token->getLine();
$stream = $this->parser->getStream();
$vars = new ArrayExpression(array(), $lineno);
$vars = new ArrayExpression([], $lineno);
$count = $this->parser->getExpressionParser()->parseExpression();
@@ -65,10 +60,10 @@ class TransChoiceTokenParser extends TransTokenParser
$stream->expect(Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
$body = $this->parser->subparse([$this, 'decideTransChoiceFork'], true);
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
}
$stream->expect(Token::BLOCK_END_TYPE);
@@ -78,13 +73,11 @@ class TransChoiceTokenParser extends TransTokenParser
public function decideTransChoiceFork($token)
{
return $token->test(array('endtranschoice'));
return $token->test(['endtranschoice']);
}
/**
* Gets the tag name associated with this token parser.
*
* @return string The tag name
* {@inheritdoc}
*/
public function getTag()
{

View File

@@ -12,7 +12,6 @@
namespace Symfony\Bridge\Twig\TokenParser;
use Symfony\Bridge\Twig\Node\TransDefaultDomainNode;
use Twig\Node\Node;
use Twig\Token;
use Twig\TokenParser\AbstractTokenParser;
@@ -24,9 +23,7 @@ use Twig\TokenParser\AbstractTokenParser;
class TransDefaultDomainTokenParser extends AbstractTokenParser
{
/**
* Parses a token and returns a node.
*
* @return Node
* {@inheritdoc}
*/
public function parse(Token $token)
{
@@ -38,9 +35,7 @@ class TransDefaultDomainTokenParser extends AbstractTokenParser
}
/**
* Gets the tag name associated with this token parser.
*
* @return string The tag name
* {@inheritdoc}
*/
public function getTag()
{

View File

@@ -15,7 +15,6 @@ use Symfony\Bridge\Twig\Node\TransNode;
use Twig\Error\SyntaxError;
use Twig\Node\Expression\AbstractExpression;
use Twig\Node\Expression\ArrayExpression;
use Twig\Node\Node;
use Twig\Node\TextNode;
use Twig\Token;
use Twig\TokenParser\AbstractTokenParser;
@@ -28,18 +27,14 @@ use Twig\TokenParser\AbstractTokenParser;
class TransTokenParser extends AbstractTokenParser
{
/**
* Parses a token and returns a node.
*
* @return Node
*
* @throws SyntaxError
* {@inheritdoc}
*/
public function parse(Token $token)
{
$lineno = $token->getLine();
$stream = $this->parser->getStream();
$vars = new ArrayExpression(array(), $lineno);
$vars = new ArrayExpression([], $lineno);
$domain = null;
$locale = null;
if (!$stream->test(Token::BLOCK_END_TYPE)) {
@@ -60,16 +55,16 @@ class TransTokenParser extends AbstractTokenParser
$stream->next();
$locale = $this->parser->getExpressionParser()->parseExpression();
} elseif (!$stream->test(Token::BLOCK_END_TYPE)) {
throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext()->getName());
throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
}
}
// {% trans %}message{% endtrans %}
$stream->expect(Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
$body = $this->parser->subparse([$this, 'decideTransFork'], true);
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
}
$stream->expect(Token::BLOCK_END_TYPE);
@@ -79,13 +74,11 @@ class TransTokenParser extends AbstractTokenParser
public function decideTransFork($token)
{
return $token->test(array('endtrans'));
return $token->test(['endtrans']);
}
/**
* Gets the tag name associated with this token parser.
*
* @return string The tag name
* {@inheritdoc}
*/
public function getTag()
{