diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-01 15:20:12 -0400 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-01 15:20:12 -0400 |
| commit | 0fe552857468aa12097a74e08f51f5aaa983be07 (patch) | |
| tree | 22dbca1be90d7086b20a077752552296abf23325 /inc/lib/Twig/Token.php | |
| parent | 22f3a95e0e421de05a11633eac846df96a2a4768 (diff) | |
Upgrade Twig library
Diffstat (limited to 'inc/lib/Twig/Token.php')
| -rw-r--r-- | inc/lib/Twig/Token.php | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/inc/lib/Twig/Token.php b/inc/lib/Twig/Token.php index 79a10030..bbca90db 100644 --- a/inc/lib/Twig/Token.php +++ b/inc/lib/Twig/Token.php @@ -13,8 +13,7 @@ /** * Represents a Token. * - * @package twig - * @author Fabien Potencier <fabien@symfony.com> + * @author Fabien Potencier <fabien@symfony.com> */ class Twig_Token { @@ -22,17 +21,19 @@ 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 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. @@ -120,10 +121,11 @@ class Twig_Token * * @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 * * @return string The string representation */ - static public function typeToString($type, $short = false, $line = -1) + public static function typeToString($type, $short = false, $line = -1) { switch ($type) { case self::EOF_TYPE: @@ -159,8 +161,14 @@ class Twig_Token case self::PUNCTUATION_TYPE: $name = 'PUNCTUATION_TYPE'; break; + case self::INTERPOLATION_START_TYPE: + $name = 'INTERPOLATION_START_TYPE'; + break; + case self::INTERPOLATION_END_TYPE: + $name = 'INTERPOLATION_END_TYPE'; + break; default: - throw new Twig_Error_Syntax(sprintf('Token of type "%s" does not exist.', $type), $line); + throw new LogicException(sprintf('Token of type "%s" does not exist.', $type)); } return $short ? $name : 'Twig_Token::'.$name; @@ -169,12 +177,12 @@ class Twig_Token /** * Returns the english representation 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 $type The type as an integer + * @param integer $line The code line * * @return string The string representation */ - static public function typeToEnglish($type, $line = -1) + public static function typeToEnglish($type, $line = -1) { switch ($type) { case self::EOF_TYPE: @@ -199,8 +207,12 @@ class Twig_Token return 'operator'; case self::PUNCTUATION_TYPE: return 'punctuation'; + case self::INTERPOLATION_START_TYPE: + return 'begin of string interpolation'; + case self::INTERPOLATION_END_TYPE: + return 'end of string interpolation'; default: - throw new Twig_Error_Syntax(sprintf('Token of type "%s" does not exist.', $type), $line); + throw new LogicException(sprintf('Token of type "%s" does not exist.', $type)); } } } |
