: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* This file is part of Twig.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
namespace WPML\Core\Twig;
* @author Fabien Potencier <fabien@symfony.com>
const BLOCK_START_TYPE = 1;
const VAR_START_TYPE = 2;
const BLOCK_END_TYPE = 3;
const PUNCTUATION_TYPE = 9;
const INTERPOLATION_START_TYPE = 10;
const INTERPOLATION_END_TYPE = 11;
* @param int $type The type of the token
* @param string $value The token value
* @param int $lineno The line position in the source
public function __construct($type, $value, $lineno)
public function __toString()
return \sprintf('%s(%s)', self::typeToString($this->type, \true), $this->value);
* Tests the current token for a type and/or a value.
* * type and value (or array of possible values)
* * just value (or array of possible values) (NAME_TYPE is used as type)
* @param array|string|int $type The type to test
* @param array|string|null $values The token value
public function test($type, $values = null)
if (null === $values && !\is_int($type)) {
return $this->type === $type && (null === $values || \is_array($values) && \in_array($this->value, $values) || $this->value == $values);
public function getLine()
public function getType()
public function getValue()
* Returns the constant representation (internal) of a given type.
* @param int $type The type as an integer
* @param bool $short Whether to return a short representation or not
* @return string The string representation
public static function typeToString($type, $short = \false)
case self::BLOCK_START_TYPE:
$name = 'BLOCK_START_TYPE';
case self::VAR_START_TYPE:
$name = 'VAR_START_TYPE';
case self::BLOCK_END_TYPE:
$name = 'BLOCK_END_TYPE';
case self::OPERATOR_TYPE:
case self::PUNCTUATION_TYPE:
$name = 'PUNCTUATION_TYPE';
case self::INTERPOLATION_START_TYPE:
$name = 'INTERPOLATION_START_TYPE';
case self::INTERPOLATION_END_TYPE:
$name = 'INTERPOLATION_END_TYPE';
throw new \LogicException(\sprintf('Token of type "%s" does not exist.', $type));
return $short ? $name : 'Twig\\Token::' . $name;
* Returns the English representation of a given type.
* @param int $type The type as an integer
* @return string The string representation
public static function typeToEnglish($type)
return 'end of template';
case self::BLOCK_START_TYPE:
return 'begin of statement block';
case self::VAR_START_TYPE:
return 'begin of print statement';
case self::BLOCK_END_TYPE:
return 'end of statement block';
return 'end of print statement';
case self::OPERATOR_TYPE:
case self::PUNCTUATION_TYPE:
case self::INTERPOLATION_START_TYPE:
return 'begin of string interpolation';
case self::INTERPOLATION_END_TYPE:
return 'end of string interpolation';
throw new \LogicException(\sprintf('Token of type "%s" does not exist.', $type));
\class_alias('WPML\\Core\\Twig\\Token', 'WPML\\Core\\Twig_Token');