summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/Token.php
diff options
context:
space:
mode:
authorBenjamin Southall <applemansigloo@gmail.com>2019-02-26 10:11:12 +1000
committerBenjamin Southall <applemansigloo@gmail.com>2019-02-26 10:11:12 +1000
commitf79395851b044689567e0e6c9504acbcaa742782 (patch)
treeee539aee9ffa90e8accd6f130b30a8ebed7a232e /inc/lib/Twig/Token.php
parent28f32baf0125ca5085266e73dc5071e5814d8e3b (diff)
Twig update to latest Twig 1.x legacy as per vichan
Diffstat (limited to 'inc/lib/Twig/Token.php')
-rw-r--r--inc/lib/Twig/Token.php89
1 files changed, 39 insertions, 50 deletions
diff --git a/inc/lib/Twig/Token.php b/inc/lib/Twig/Token.php
index bbca90db..89066869 100644
--- a/inc/lib/Twig/Token.php
+++ b/inc/lib/Twig/Token.php
@@ -3,8 +3,8 @@
/*
* This file is part of Twig.
*
- * (c) 2009 Fabien Potencier
- * (c) 2009 Armin Ronacher
+ * (c) Fabien Potencier
+ * (c) Armin Ronacher
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -14,6 +14,8 @@
* Represents a Token.
*
* @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @final
*/
class Twig_Token
{
@@ -21,56 +23,49 @@ class Twig_Token
protected $type;
protected $lineno;
- const EOF_TYPE = -1;
- const TEXT_TYPE = 0;
- const BLOCK_START_TYPE = 1;
- const VAR_START_TYPE = 2;
- const BLOCK_END_TYPE = 3;
- const VAR_END_TYPE = 4;
- const NAME_TYPE = 5;
- const NUMBER_TYPE = 6;
- const STRING_TYPE = 7;
- const OPERATOR_TYPE = 8;
- const PUNCTUATION_TYPE = 9;
- const INTERPOLATION_START_TYPE = 10;
- const INTERPOLATION_END_TYPE = 11;
+ const EOF_TYPE = -1;
+ const TEXT_TYPE = 0;
+ const BLOCK_START_TYPE = 1;
+ const VAR_START_TYPE = 2;
+ const BLOCK_END_TYPE = 3;
+ const VAR_END_TYPE = 4;
+ const NAME_TYPE = 5;
+ const NUMBER_TYPE = 6;
+ const STRING_TYPE = 7;
+ const OPERATOR_TYPE = 8;
+ const PUNCTUATION_TYPE = 9;
+ const INTERPOLATION_START_TYPE = 10;
+ const INTERPOLATION_END_TYPE = 11;
/**
- * Constructor.
- *
- * @param integer $type The type of the token
- * @param string $value The token value
- * @param integer $lineno The line position in the source
+ * @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)
{
- $this->type = $type;
- $this->value = $value;
+ $this->type = $type;
+ $this->value = $value;
$this->lineno = $lineno;
}
- /**
- * Returns a string representation of the token.
- *
- * @return string A string representation of the token
- */
public function __toString()
{
- return sprintf('%s(%s)', self::typeToString($this->type, true, $this->lineno), $this->value);
+ return sprintf('%s(%s)', self::typeToString($this->type, true), $this->value);
}
/**
* Tests the current token for a type and/or a value.
*
* Parameters may be:
- * * just type
- * * type and value (or array of possible values)
- * * just value (or array of possible values) (NAME_TYPE is used as type)
+ * * just type
+ * * type and value (or array of possible values)
+ * * just value (or array of possible values) (NAME_TYPE is used as type)
*
- * @param array|integer $type The type to test
+ * @param array|string|int $type The type to test
* @param array|string|null $values The token value
*
- * @return Boolean
+ * @return bool
*/
public function test($type, $values = null)
{
@@ -87,9 +82,7 @@ class Twig_Token
}
/**
- * Gets the line.
- *
- * @return integer The source line
+ * @return int
*/
public function getLine()
{
@@ -97,9 +90,7 @@ class Twig_Token
}
/**
- * Gets the token type.
- *
- * @return integer The token type
+ * @return int
*/
public function getType()
{
@@ -107,9 +98,7 @@ class Twig_Token
}
/**
- * Gets the token value.
- *
- * @return string The token value
+ * @return string
*/
public function getValue()
{
@@ -119,13 +108,12 @@ class Twig_Token
/**
* Returns the constant representation (internal) of a given type.
*
- * @param integer $type The type as an integer
- * @param Boolean $short Whether to return a short representation or not
- * @param integer $line The code line
+ * @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, $line = -1)
+ public static function typeToString($type, $short = false)
{
switch ($type) {
case self::EOF_TYPE:
@@ -175,14 +163,13 @@ class Twig_Token
}
/**
- * Returns the english representation of a given type.
+ * Returns the English representation of a given type.
*
- * @param integer $type The type as an integer
- * @param integer $line The code line
+ * @param int $type The type as an integer
*
* @return string The string representation
*/
- public static function typeToEnglish($type, $line = -1)
+ public static function typeToEnglish($type)
{
switch ($type) {
case self::EOF_TYPE:
@@ -216,3 +203,5 @@ class Twig_Token
}
}
}
+
+class_alias('Twig_Token', 'Twig\Token', false);