Skip to content

Commit

Permalink
minor #2105 Floor - use cast and not intval (SpacePossum)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 1.x branch (closes #2105).

Discussion
----------

Floor - use cast and not intval

Use cast in fav. of the `inval`, because;
- its faster
- cannot be overloaded
- less chars

Commits
-------

39d46ac Floor - use cast and not intval
  • Loading branch information
fabpot committed Aug 31, 2016
2 parents ffa2b81 + 39d46ac commit 50b1b87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Twig/Node/Expression/Binary/FloorDiv.php
Expand Up @@ -12,9 +12,9 @@ class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary
{
public function compile(Twig_Compiler $compiler)
{
$compiler->raw('intval(floor(');
$compiler->raw('(int) floor(');
parent::compile($compiler);
$compiler->raw('))');
$compiler->raw(')');
}

public function operator(Twig_Compiler $compiler)
Expand Down
2 changes: 1 addition & 1 deletion test/Twig/Tests/Node/Expression/Binary/FloorDivTest.php
Expand Up @@ -28,7 +28,7 @@ public function getTests()
$node = new Twig_Node_Expression_Binary_FloorDiv($left, $right, 1);

return array(
array($node, 'intval(floor((1 / 2)))'),
array($node, '(int) floor((1 / 2))'),
);
}
}

0 comments on commit 50b1b87

Please sign in to comment.