mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-01 21:17:21 +00:00
Improve YieldReady support docs
This commit is contained in:
@@ -183,6 +183,12 @@ Nodes
|
||||
Twig 3.15; use ``Twig\Node\Expression\Variable\AssignContextVariable``
|
||||
instead.
|
||||
|
||||
* Node implementations that use ``echo`` or ``print`` should use ``yield``
|
||||
instead; all Node implementations should use the
|
||||
``#[\Twig\Attribute\YieldReady]`` attribute on their class once they've been
|
||||
made ready for ``yield``; the ``use_yield`` Environment option can be turned
|
||||
on when all nodes use the ``#[\Twig\Attribute\YieldReady]`` attribute.
|
||||
|
||||
Node Visitors
|
||||
-------------
|
||||
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ class Compiler
|
||||
$node->compile($this);
|
||||
|
||||
if ($this->didUseEcho) {
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[YieldReady].', $this->didUseEcho, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[\Twig\Attribute\YieldReady].', $this->didUseEcho, \get_class($node));
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -99,7 +99,7 @@ class Compiler
|
||||
$node->compile($this);
|
||||
|
||||
if ($this->didUseEcho) {
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[YieldReady].', $this->didUseEcho, \get_class($node));
|
||||
trigger_deprecation('twig/twig', '3.9', 'Using "%s" is deprecated, use "yield" instead in "%s", then flag the class with #[\Twig\Attribute\YieldReady].', $this->didUseEcho, \get_class($node));
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -41,7 +41,7 @@ final class YieldNotReadyNodeVisitor implements NodeVisitorInterface
|
||||
throw new \LogicException(\sprintf('You cannot enable the "use_yield" option of Twig as node "%s" is not marked as ready for it; please make it ready and then flag it with the #[YieldReady] attribute.', $class));
|
||||
}
|
||||
|
||||
trigger_deprecation('twig/twig', '3.9', 'Twig node "%s" is not marked as ready for using "yield" instead of "echo"; please make it ready and then flag it with the #[YieldReady] attribute.', $class);
|
||||
trigger_deprecation('twig/twig', '3.9', 'Twig node "%s" is not marked as ready for using "yield" instead of "echo"; please make it ready and then flag it with the #[\Twig\Attribute\YieldReady] attribute.', $class);
|
||||
}
|
||||
|
||||
return $node;
|
||||
|
||||
@@ -445,11 +445,11 @@ class EnvironmentTest extends TestCase
|
||||
|
||||
if ($twig->useYield()) {
|
||||
$this->expectException(SyntaxError::class);
|
||||
$this->expectExceptionMessage('An exception has been thrown during the compilation of a template ("You cannot enable the "use_yield" option of Twig as node "Twig\Tests\EnvironmentTest_LegacyEchoingNode" is not marked as ready for it; please make it ready and then flag it with the #[YieldReady] attribute.") in "echo_bar".');
|
||||
$this->expectExceptionMessage('An exception has been thrown during the compilation of a template ("You cannot enable the "use_yield" option of Twig as node "Twig\Tests\EnvironmentTest_LegacyEchoingNode" is not marked as ready for it; please make it ready and then flag it with the #[\Twig\Attribute\YieldReady] attribute.") in "echo_bar".');
|
||||
} else {
|
||||
$this->expectDeprecation(<<<'EOF'
|
||||
Since twig/twig 3.9: Twig node "Twig\Tests\EnvironmentTest_LegacyEchoingNode" is not marked as ready for using "yield" instead of "echo"; please make it ready and then flag it with the #[YieldReady] attribute.
|
||||
Since twig/twig 3.9: Using "echo" is deprecated, use "yield" instead in "Twig\Tests\EnvironmentTest_LegacyEchoingNode", then flag the class with #[YieldReady].
|
||||
Since twig/twig 3.9: Twig node "Twig\Tests\EnvironmentTest_LegacyEchoingNode" is not marked as ready for using "yield" instead of "echo"; please make it ready and then flag it with the #[\Twig\Attribute\YieldReady] attribute.
|
||||
Since twig/twig 3.9: Using "echo" is deprecated, use "yield" instead in "Twig\Tests\EnvironmentTest_LegacyEchoingNode", then flag the class with #[\Twig\Attribute\YieldReady].
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user