Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/sitepres.../lib/twig/src
File: TokenStream.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*
[2] Fix | Delete
* This file is part of Twig.
[3] Fix | Delete
*
[4] Fix | Delete
* (c) Fabien Potencier
[5] Fix | Delete
* (c) Armin Ronacher
[6] Fix | Delete
*
[7] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[8] Fix | Delete
* file that was distributed with this source code.
[9] Fix | Delete
*/
[10] Fix | Delete
namespace WPML\Core\Twig;
[11] Fix | Delete
[12] Fix | Delete
use WPML\Core\Twig\Error\SyntaxError;
[13] Fix | Delete
/**
[14] Fix | Delete
* Represents a token stream.
[15] Fix | Delete
*
[16] Fix | Delete
* @final
[17] Fix | Delete
*
[18] Fix | Delete
* @author Fabien Potencier <fabien@symfony.com>
[19] Fix | Delete
*/
[20] Fix | Delete
class TokenStream
[21] Fix | Delete
{
[22] Fix | Delete
protected $tokens;
[23] Fix | Delete
protected $current = 0;
[24] Fix | Delete
protected $filename;
[25] Fix | Delete
private $source;
[26] Fix | Delete
/**
[27] Fix | Delete
* @param array $tokens An array of tokens
[28] Fix | Delete
* @param string|null $name The name of the template which tokens are associated with
[29] Fix | Delete
* @param string|null $source The source code associated with the tokens
[30] Fix | Delete
*/
[31] Fix | Delete
public function __construct(array $tokens, $name = null, $source = null)
[32] Fix | Delete
{
[33] Fix | Delete
if (!$name instanceof \WPML\Core\Twig\Source) {
[34] Fix | Delete
if (null !== $name || null !== $source) {
[35] Fix | Delete
@\trigger_error(\sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a \\Twig\\Source instance instead.', __METHOD__), \E_USER_DEPRECATED);
[36] Fix | Delete
}
[37] Fix | Delete
$this->source = new \WPML\Core\Twig\Source($source, $name);
[38] Fix | Delete
} else {
[39] Fix | Delete
$this->source = $name;
[40] Fix | Delete
}
[41] Fix | Delete
$this->tokens = $tokens;
[42] Fix | Delete
// deprecated, not used anymore, to be removed in 2.0
[43] Fix | Delete
$this->filename = $this->source->getName();
[44] Fix | Delete
}
[45] Fix | Delete
public function __toString()
[46] Fix | Delete
{
[47] Fix | Delete
return \implode("\n", $this->tokens);
[48] Fix | Delete
}
[49] Fix | Delete
public function injectTokens(array $tokens)
[50] Fix | Delete
{
[51] Fix | Delete
$this->tokens = \array_merge(\array_slice($this->tokens, 0, $this->current), $tokens, \array_slice($this->tokens, $this->current));
[52] Fix | Delete
}
[53] Fix | Delete
/**
[54] Fix | Delete
* Sets the pointer to the next token and returns the old one.
[55] Fix | Delete
*
[56] Fix | Delete
* @return Token
[57] Fix | Delete
*/
[58] Fix | Delete
public function next()
[59] Fix | Delete
{
[60] Fix | Delete
if (!isset($this->tokens[++$this->current])) {
[61] Fix | Delete
throw new \WPML\Core\Twig\Error\SyntaxError('Unexpected end of template.', $this->tokens[$this->current - 1]->getLine(), $this->source);
[62] Fix | Delete
}
[63] Fix | Delete
return $this->tokens[$this->current - 1];
[64] Fix | Delete
}
[65] Fix | Delete
/**
[66] Fix | Delete
* Tests a token, sets the pointer to the next one and returns it or throws a syntax error.
[67] Fix | Delete
*
[68] Fix | Delete
* @return Token|null The next token if the condition is true, null otherwise
[69] Fix | Delete
*/
[70] Fix | Delete
public function nextIf($primary, $secondary = null)
[71] Fix | Delete
{
[72] Fix | Delete
if ($this->tokens[$this->current]->test($primary, $secondary)) {
[73] Fix | Delete
return $this->next();
[74] Fix | Delete
}
[75] Fix | Delete
}
[76] Fix | Delete
/**
[77] Fix | Delete
* Tests a token and returns it or throws a syntax error.
[78] Fix | Delete
*
[79] Fix | Delete
* @return Token
[80] Fix | Delete
*/
[81] Fix | Delete
public function expect($type, $value = null, $message = null)
[82] Fix | Delete
{
[83] Fix | Delete
$token = $this->tokens[$this->current];
[84] Fix | Delete
if (!$token->test($type, $value)) {
[85] Fix | Delete
$line = $token->getLine();
[86] Fix | Delete
throw new \WPML\Core\Twig\Error\SyntaxError(\sprintf('%sUnexpected token "%s"%s ("%s" expected%s).', $message ? $message . '. ' : '', \WPML\Core\Twig\Token::typeToEnglish($token->getType()), $token->getValue() ? \sprintf(' of value "%s"', $token->getValue()) : '', \WPML\Core\Twig\Token::typeToEnglish($type), $value ? \sprintf(' with value "%s"', $value) : ''), $line, $this->source);
[87] Fix | Delete
}
[88] Fix | Delete
$this->next();
[89] Fix | Delete
return $token;
[90] Fix | Delete
}
[91] Fix | Delete
/**
[92] Fix | Delete
* Looks at the next token.
[93] Fix | Delete
*
[94] Fix | Delete
* @param int $number
[95] Fix | Delete
*
[96] Fix | Delete
* @return Token
[97] Fix | Delete
*/
[98] Fix | Delete
public function look($number = 1)
[99] Fix | Delete
{
[100] Fix | Delete
if (!isset($this->tokens[$this->current + $number])) {
[101] Fix | Delete
throw new \WPML\Core\Twig\Error\SyntaxError('Unexpected end of template.', $this->tokens[$this->current + $number - 1]->getLine(), $this->source);
[102] Fix | Delete
}
[103] Fix | Delete
return $this->tokens[$this->current + $number];
[104] Fix | Delete
}
[105] Fix | Delete
/**
[106] Fix | Delete
* Tests the current token.
[107] Fix | Delete
*
[108] Fix | Delete
* @return bool
[109] Fix | Delete
*/
[110] Fix | Delete
public function test($primary, $secondary = null)
[111] Fix | Delete
{
[112] Fix | Delete
return $this->tokens[$this->current]->test($primary, $secondary);
[113] Fix | Delete
}
[114] Fix | Delete
/**
[115] Fix | Delete
* Checks if end of stream was reached.
[116] Fix | Delete
*
[117] Fix | Delete
* @return bool
[118] Fix | Delete
*/
[119] Fix | Delete
public function isEOF()
[120] Fix | Delete
{
[121] Fix | Delete
return \WPML\Core\Twig\Token::EOF_TYPE === $this->tokens[$this->current]->getType();
[122] Fix | Delete
}
[123] Fix | Delete
/**
[124] Fix | Delete
* @return Token
[125] Fix | Delete
*/
[126] Fix | Delete
public function getCurrent()
[127] Fix | Delete
{
[128] Fix | Delete
return $this->tokens[$this->current];
[129] Fix | Delete
}
[130] Fix | Delete
/**
[131] Fix | Delete
* Gets the name associated with this stream (null if not defined).
[132] Fix | Delete
*
[133] Fix | Delete
* @return string|null
[134] Fix | Delete
*
[135] Fix | Delete
* @deprecated since 1.27 (to be removed in 2.0)
[136] Fix | Delete
*/
[137] Fix | Delete
public function getFilename()
[138] Fix | Delete
{
[139] Fix | Delete
@\trigger_error(\sprintf('The %s() method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), \E_USER_DEPRECATED);
[140] Fix | Delete
return $this->source->getName();
[141] Fix | Delete
}
[142] Fix | Delete
/**
[143] Fix | Delete
* Gets the source code associated with this stream.
[144] Fix | Delete
*
[145] Fix | Delete
* @return string
[146] Fix | Delete
*
[147] Fix | Delete
* @internal Don't use this as it might be empty depending on the environment configuration
[148] Fix | Delete
*
[149] Fix | Delete
* @deprecated since 1.27 (to be removed in 2.0)
[150] Fix | Delete
*/
[151] Fix | Delete
public function getSource()
[152] Fix | Delete
{
[153] Fix | Delete
@\trigger_error(\sprintf('The %s() method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), \E_USER_DEPRECATED);
[154] Fix | Delete
return $this->source->getCode();
[155] Fix | Delete
}
[156] Fix | Delete
/**
[157] Fix | Delete
* Gets the source associated with this stream.
[158] Fix | Delete
*
[159] Fix | Delete
* @return Source
[160] Fix | Delete
*
[161] Fix | Delete
* @internal
[162] Fix | Delete
*/
[163] Fix | Delete
public function getSourceContext()
[164] Fix | Delete
{
[165] Fix | Delete
return $this->source;
[166] Fix | Delete
}
[167] Fix | Delete
}
[168] Fix | Delete
\class_alias('WPML\\Core\\Twig\\TokenStream', 'WPML\\Core\\Twig_TokenStream');
[169] Fix | Delete
[170] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function