Floor - use cast and not intval

This commit is contained in:
SpacePossum
2016-08-29 14:21:10 +02:00
committed by Fabien Potencier
parent ffa2b812b0
commit 39d46acf7d
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -12,9 +12,9 @@ class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary
{ {
public function compile(Twig_Compiler $compiler) public function compile(Twig_Compiler $compiler)
{ {
$compiler->raw('intval(floor('); $compiler->raw('(int) floor(');
parent::compile($compiler); parent::compile($compiler);
$compiler->raw('))'); $compiler->raw(')');
} }
public function operator(Twig_Compiler $compiler) public function operator(Twig_Compiler $compiler)
@@ -28,7 +28,7 @@ class Twig_Tests_Node_Expression_Binary_FloorDivTest extends Twig_Test_NodeTestC
$node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1); $node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1);
return array( return array(
array($node, 'intval(floor((1 / 2)))'), array($node, '(int) floor((1 / 2))'),
); );
} }
} }