Bug correction: Parsing integers large than PHP_INT_MAX was generating trucated token values.

This commit is contained in:
Paulo Roberto Ribeiro
2011-12-01 18:41:28 -02:00
parent 046e4ffa23
commit 7aa67572e8
+4 -4
View File
@@ -221,10 +221,10 @@ class Twig_Lexer implements Twig_LexerInterface
}
// numbers
elseif (preg_match(self::REGEX_NUMBER, $this->code, $match, null, $this->cursor)) {
$number = (float)$match[0]; // floats
if(ctype_digit($match[0])) {
if($number<=PHP_INT_MAX) {
$number = (int)$match[0]; // integers lower than the maximum
$number = (float) $match[0]; // floats
if (ctype_digit($match[0])) {
if ($number <= PHP_INT_MAX) {
$number = (int) $match[0]; // integers lower than the maximum
}
}
$this->pushToken(Twig_Token::NUMBER_TYPE, $number);