Merge branch '2.x' into 3.x

* 2.x:
  fix node class namespace
This commit is contained in:
Fabien Potencier
2020-03-24 13:35:36 +01:00
+10 -4
View File
@@ -326,14 +326,20 @@ When creating tests you can use the ``node_class`` option to provide custom test
compilation. This is useful if your test can be compiled into PHP primitives.
This is used by many of the tests built into Twig::
$twig = new \Twig\Environment($loader);
$test = new \Twig\TwigTest(
namespace App;
use Twig\Environment;
use Twig\Node\Expression\TestExpression;
use Twig\TwigTest;
$twig = new Environment($loader);
$test = new TwigTest(
'odd',
null,
['node_class' => \Twig\Node\Expression\Test\OddTest::class]);
['node_class' => OddTestExpression::class]);
$twig->addTest($test);
class Twig_Node_Expression_Test_Odd extends \Twig\Node\Expression\TestExpression
class OddTestExpression extends TestExpression
{
public function compile(\Twig\Compiler $compiler)
{