[ticket/16382] Update Twig_Token

PHPBB3-16382
This commit is contained in:
mrgoldy 2020-02-27 16:42:44 +01:00
parent dbb9cbe280
commit b795b8a040
7 changed files with 28 additions and 28 deletions

View file

@ -19,20 +19,20 @@ class defineparser extends \Twig_TokenParser
/** /**
* Parses a token and returns a node. * Parses a token and returns a node.
* *
* @param \Twig_Token $token A Twig_Token instance * @param \Twig\Token $token A Twig_Token instance
* *
* @return \Twig_Node A Twig_Node instance * @return \Twig_Node A Twig_Node instance
* @throws \Twig_Error_Syntax * @throws \Twig_Error_Syntax
* @throws \phpbb\template\twig\node\definenode * @throws \phpbb\template\twig\node\definenode
*/ */
public function parse(\Twig_Token $token) public function parse(\Twig\Token $token)
{ {
$lineno = $token->getLine(); $lineno = $token->getLine();
$stream = $this->parser->getStream(); $stream = $this->parser->getStream();
$name = $this->parser->getExpressionParser()->parseExpression(); $name = $this->parser->getExpressionParser()->parseExpression();
$capture = false; $capture = false;
if ($stream->test(\Twig_Token::OPERATOR_TYPE, '=')) if ($stream->test(\Twig\Token::OPERATOR_TYPE, '='))
{ {
$stream->next(); $stream->next();
$value = $this->parser->getExpressionParser()->parseExpression(); $value = $this->parser->getExpressionParser()->parseExpression();
@ -44,22 +44,22 @@ class defineparser extends \Twig_TokenParser
throw new \Twig_Error_Syntax('Invalid DEFINE', $token->getLine(), $this->parser->getStream()->getSourceContext()->getPath()); throw new \Twig_Error_Syntax('Invalid DEFINE', $token->getLine(), $this->parser->getStream()->getSourceContext()->getPath());
} }
$stream->expect(\Twig_Token::BLOCK_END_TYPE); $stream->expect(\Twig\Token::BLOCK_END_TYPE);
} }
else else
{ {
$capture = true; $capture = true;
$stream->expect(\Twig_Token::BLOCK_END_TYPE); $stream->expect(\Twig\Token::BLOCK_END_TYPE);
$value = $this->parser->subparse(array($this, 'decideBlockEnd'), true); $value = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
$stream->expect(\Twig_Token::BLOCK_END_TYPE); $stream->expect(\Twig\Token::BLOCK_END_TYPE);
} }
return new \phpbb\template\twig\node\definenode($capture, $name, $value, $lineno, $this->getTag()); return new \phpbb\template\twig\node\definenode($capture, $name, $value, $lineno, $this->getTag());
} }
public function decideBlockEnd(\Twig_Token $token) public function decideBlockEnd(\Twig\Token $token)
{ {
return $token->test('ENDDEFINE'); return $token->test('ENDDEFINE');
} }

View file

@ -31,16 +31,16 @@ class event extends \Twig_TokenParser
/** /**
* Parses a token and returns a node. * Parses a token and returns a node.
* *
* @param \Twig_Token $token A Twig_Token instance * @param \Twig\Token $token A Twig_Token instance
* *
* @return \Twig_Node A Twig_Node instance * @return \Twig_Node A Twig_Node instance
*/ */
public function parse(\Twig_Token $token) public function parse(\Twig\Token $token)
{ {
$expr = $this->parser->getExpressionParser()->parseExpression(); $expr = $this->parser->getExpressionParser()->parseExpression();
$stream = $this->parser->getStream(); $stream = $this->parser->getStream();
$stream->expect(\Twig_Token::BLOCK_END_TYPE); $stream->expect(\Twig\Token::BLOCK_END_TYPE);
return new \phpbb\template\twig\node\event($expr, $this->environment, $token->getLine(), $this->getTag()); return new \phpbb\template\twig\node\event($expr, $this->environment, $token->getLine(), $this->getTag());
} }

View file

@ -18,16 +18,16 @@ class includecss extends \Twig_TokenParser
/** /**
* Parses a token and returns a node. * Parses a token and returns a node.
* *
* @param \Twig_Token $token A Twig_Token instance * @param \Twig\Token $token A Twig_Token instance
* *
* @return \Twig_Node A Twig_Node instance * @return \Twig_Node A Twig_Node instance
*/ */
public function parse(\Twig_Token $token) public function parse(\Twig\Token $token)
{ {
$expr = $this->parser->getExpressionParser()->parseExpression(); $expr = $this->parser->getExpressionParser()->parseExpression();
$stream = $this->parser->getStream(); $stream = $this->parser->getStream();
$stream->expect(\Twig_Token::BLOCK_END_TYPE); $stream->expect(\Twig\Token::BLOCK_END_TYPE);
return new \phpbb\template\twig\node\includecss($expr, $token->getLine(), $this->getTag()); return new \phpbb\template\twig\node\includecss($expr, $token->getLine(), $this->getTag());
} }

View file

@ -18,16 +18,16 @@ class includejs extends \Twig_TokenParser
/** /**
* Parses a token and returns a node. * Parses a token and returns a node.
* *
* @param \Twig_Token $token A Twig_Token instance * @param \Twig\Token $token A Twig_Token instance
* *
* @return \Twig_Node A Twig_Node instance * @return \Twig_Node A Twig_Node instance
*/ */
public function parse(\Twig_Token $token) public function parse(\Twig\Token $token)
{ {
$expr = $this->parser->getExpressionParser()->parseExpression(); $expr = $this->parser->getExpressionParser()->parseExpression();
$stream = $this->parser->getStream(); $stream = $this->parser->getStream();
$stream->expect(\Twig_Token::BLOCK_END_TYPE); $stream->expect(\Twig\Token::BLOCK_END_TYPE);
return new \phpbb\template\twig\node\includejs($expr, $token->getLine(), $this->getTag()); return new \phpbb\template\twig\node\includejs($expr, $token->getLine(), $this->getTag());
} }

View file

@ -19,11 +19,11 @@ class includeparser extends \Twig_TokenParser_Include
/** /**
* Parses a token and returns a node. * Parses a token and returns a node.
* *
* @param \Twig_Token $token A Twig_Token instance * @param \Twig\Token $token A Twig_Token instance
* *
* @return \Twig_Node A Twig_Node instance * @return \Twig_Node A Twig_Node instance
*/ */
public function parse(\Twig_Token $token) public function parse(\Twig\Token $token)
{ {
$expr = $this->parser->getExpressionParser()->parseExpression(); $expr = $this->parser->getExpressionParser()->parseExpression();

View file

@ -32,26 +32,26 @@ class includephp extends \Twig_TokenParser
/** /**
* Parses a token and returns a node. * Parses a token and returns a node.
* *
* @param \Twig_Token $token A Twig_Token instance * @param \Twig\Token $token A Twig_Token instance
* *
* @return \Twig_Node A Twig_Node instance * @return \Twig_Node A Twig_Node instance
*/ */
public function parse(\Twig_Token $token) public function parse(\Twig\Token $token)
{ {
$expr = $this->parser->getExpressionParser()->parseExpression(); $expr = $this->parser->getExpressionParser()->parseExpression();
$stream = $this->parser->getStream(); $stream = $this->parser->getStream();
$ignoreMissing = false; $ignoreMissing = false;
if ($stream->test(\Twig_Token::NAME_TYPE, 'ignore')) if ($stream->test(\Twig\Token::NAME_TYPE, 'ignore'))
{ {
$stream->next(); $stream->next();
$stream->expect(\Twig_Token::NAME_TYPE, 'missing'); $stream->expect(\Twig\Token::NAME_TYPE, 'missing');
$ignoreMissing = true; $ignoreMissing = true;
} }
$stream->expect(\Twig_Token::BLOCK_END_TYPE); $stream->expect(\Twig\Token::BLOCK_END_TYPE);
return new \phpbb\template\twig\node\includephp($expr, $this->environment, $token->getLine(), $ignoreMissing, $this->getTag()); return new \phpbb\template\twig\node\includephp($expr, $this->environment, $token->getLine(), $ignoreMissing, $this->getTag());
} }

View file

@ -31,24 +31,24 @@ class php extends \Twig_TokenParser
/** /**
* Parses a token and returns a node. * Parses a token and returns a node.
* *
* @param \Twig_Token $token A Twig_Token instance * @param \Twig\Token $token A Twig_Token instance
* *
* @return \Twig_Node A Twig_Node instance * @return \Twig_Node A Twig_Node instance
*/ */
public function parse(\Twig_Token $token) public function parse(\Twig\Token $token)
{ {
$stream = $this->parser->getStream(); $stream = $this->parser->getStream();
$stream->expect(\Twig_Token::BLOCK_END_TYPE); $stream->expect(\Twig\Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideEnd'), true); $body = $this->parser->subparse(array($this, 'decideEnd'), true);
$stream->expect(\Twig_Token::BLOCK_END_TYPE); $stream->expect(\Twig\Token::BLOCK_END_TYPE);
return new \phpbb\template\twig\node\php($body, $this->environment, $token->getLine(), $this->getTag()); return new \phpbb\template\twig\node\php($body, $this->environment, $token->getLine(), $this->getTag());
} }
public function decideEnd(\Twig_Token $token) public function decideEnd(\Twig\Token $token)
{ {
return $token->test('ENDPHP'); return $token->test('ENDPHP');
} }