mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
bf24f136b9
The new compilation implemented in Twig 3 for PHP 7 (to match the comparison semantic of PHP 8) was missing the surrounding braces (which are part of the AsbtractBinary compilation). This caused issues when the full expression would involve other operators (like the not operator), as things would then rely on having the correct precedence in PHP (which would not be the case).
40 lines
814 B
PHP
40 lines
814 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Twig.
|
|
*
|
|
* (c) Fabien Potencier
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Twig\Node\Expression\Binary;
|
|
|
|
use Twig\Compiler;
|
|
|
|
class LessEqualBinary extends AbstractBinary
|
|
{
|
|
public function compile(Compiler $compiler): void
|
|
{
|
|
if (\PHP_VERSION_ID >= 80000) {
|
|
parent::compile($compiler);
|
|
|
|
return;
|
|
}
|
|
|
|
$compiler
|
|
->raw('(0 >= twig_compare(')
|
|
->subcompile($this->getNode('left'))
|
|
->raw(', ')
|
|
->subcompile($this->getNode('right'))
|
|
->raw('))')
|
|
;
|
|
}
|
|
|
|
public function operator(Compiler $compiler): Compiler
|
|
{
|
|
return $compiler->raw('<=');
|
|
}
|
|
}
|