From 4317a272993673ad89b7abd338a38dec39ffdb7f Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 24 Apr 2024 10:46:09 +0200 Subject: [PATCH] YieldReady (#443) * YieldReady * CS --- src/Node/EventNode.php | 7 +++---- src/Node/GetAttrNode.php | 13 ++++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Node/EventNode.php b/src/Node/EventNode.php index c09d9e1..286fa81 100644 --- a/src/Node/EventNode.php +++ b/src/Node/EventNode.php @@ -6,9 +6,11 @@ use Illuminate\Support\Str; use Illuminate\View\View; use Illuminate\View\ViewName; +use Twig\Attribute\YieldReady; use Twig\Compiler; use Twig\Node\Node; +#[YieldReady] class EventNode extends Node { @@ -16,10 +18,7 @@ public function compile(Compiler $compiler): void { $compiler ->write( - sprintf( - '$context = ' . - EventNode::class . '::triggerLaravelEvents($this->getTemplateName(), $context);' - ) + '$context = ' . EventNode::class . '::triggerLaravelEvents($this->getTemplateName(), $context);' ) ->raw("\n"); } diff --git a/src/Node/GetAttrNode.php b/src/Node/GetAttrNode.php index 81d619e..af4990b 100644 --- a/src/Node/GetAttrNode.php +++ b/src/Node/GetAttrNode.php @@ -7,6 +7,7 @@ */ namespace TwigBridge\Node; +use Twig\Attribute\YieldReady; use Twig\Compiler; use Twig\Environment; use Twig\Error\RuntimeError; @@ -24,6 +25,7 @@ * - https://github.com/rcrowe/TwigBridge/issues/362 * - https://github.com/rcrowe/TwigBridge/issues/265 */ +#[YieldReady] class GetAttrNode extends GetAttrExpression { /** @@ -145,6 +147,15 @@ public static function attribute( return $object->$item; } - return CoreExtension::getAttribute($env, $source, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck); + return CoreExtension::getAttribute( + $env, + $source, + $object, + $item, + $arguments, + $type, + $isDefinedTest, + $ignoreStrictCheck + ); } }