documentation #4958 3.x doc fixes (fabpot)

This PR was squashed before being merged into the 3.x branch.

Discussion
----------

3.x doc fixes

Commits
-------

1478f9efcd Fix the class name and a missing parenthesis in the runtime loader example
e883536e64 Replace the deprecated twig_test_even function in the custom test example
db3aeb7379 Use the current variable node class in the node tree example
This commit is contained in:
Fabien Potencier
2026-09-26 10:36:51 +02:00
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -848,7 +848,7 @@ The ``getTests()`` method lets you add new test functions::
public function getTests()
{
return [
new \Twig\TwigTest('even', 'twig_test_even'),
new \Twig\TwigTest('even', fn (int $value): bool => 0 === $value % 2),
];
}
@@ -919,8 +919,8 @@ a runtime extension using one of the runtime loaders::
}
$twig = new \Twig\Environment($loader);
$twig->addExtension(new \Twig\Extension\AttributeExtension(ProjectExtension::class);
$twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryLoader([
$twig->addExtension(new \Twig\Extension\AttributeExtension(ProjectExtension::class));
$twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader([
ProjectExtension::class => function () use ($lipsumProvider) {
return new ProjectExtension($lipsumProvider);
},
+1 -1
View File
@@ -95,7 +95,7 @@ Here is the output for the ``Hello {{ name }}`` template:
\Twig\Node\ModuleNode(
\Twig\Node\TextNode(Hello )
\Twig\Node\PrintNode(
\Twig\Node\Expression\NameExpression(name)
\Twig\Node\Expression\Variable\ContextVariable(name)
)
)