Deprecate not passing a BodyNode instance as the body of a ModuleNode constructor

This commit is contained in:
Fabien Potencier
2024-08-24 10:49:53 +02:00
parent fb46572f94
commit 51e93aa130
7 changed files with 29 additions and 8 deletions
+7
View File
@@ -30,8 +30,15 @@ use Twig\Source;
#[YieldReady]
final class ModuleNode extends Node
{
/**
* @param BodyNode $body
*/
public function __construct(Node $body, ?AbstractExpression $parent, Node $blocks, Node $macros, Node $traits, $embeddedTemplates, Source $source)
{
if (!$body instanceof BodyNode) {
trigger_deprecation('twig/twig', '3.12', sprintf('Not passing a "%s" instance as the "body" argument of the "%s" constructor is deprecated.', BodyNode::class, __CLASS__));
}
$nodes = [
'body' => $body,
'blocks' => $blocks,