From 4cd8955f74fdecbb91b35cd1c898e08c0075dd53 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Thu, 5 Sep 2024 09:24:38 +0200 Subject: [PATCH] Fix iterable return type Currently, the PHPDoc states that a string should be returned, but that's not correct. It can be anything that is echo-able. That means any scalar, Stringable and even null. --- src/Node/BlockNode.php | 2 +- src/Template.php | 8 ++++---- tests/Node/BlockTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Node/BlockNode.php b/src/Node/BlockNode.php index 3c06f155b..b4f939cf6 100644 --- a/src/Node/BlockNode.php +++ b/src/Node/BlockNode.php @@ -33,7 +33,7 @@ class BlockNode extends Node $compiler ->addDebugInfo($this) ->write("/**\n") - ->write(" * @return iterable\n") + ->write(" * @return iterable\n") ->write(" */\n") ->write(\sprintf("public function block_%s(array \$context, array \$blocks = []): iterable\n", $this->getAttribute('name')), "{\n") ->indent() diff --git a/src/Template.php b/src/Template.php index 2dc05686d..e6bf2486a 100644 --- a/src/Template.php +++ b/src/Template.php @@ -382,7 +382,7 @@ abstract class Template } /** - * @return iterable + * @return iterable */ public function yield(array $context, array $blocks = []): iterable { @@ -412,7 +412,7 @@ abstract class Template } /** - * @return iterable + * @return iterable */ public function yieldBlock($name, array $context, array $blocks = [], $useBlocks = true, ?self $templateContext = null): iterable { @@ -472,7 +472,7 @@ abstract class Template * @param array $context The context * @param array $blocks The current set of blocks * - * @return iterable + * @return iterable */ public function yieldParentBlock($name, array $context, array $blocks = []): iterable { @@ -491,7 +491,7 @@ abstract class Template * @param array $context An array of parameters to pass to the template * @param array $blocks An array of blocks to pass to the template * - * @return iterable + * @return iterable */ abstract protected function doDisplay(array $context, array $blocks = []): iterable; } diff --git a/tests/Node/BlockTest.php b/tests/Node/BlockTest.php index af110e32a..2304c8abd 100644 --- a/tests/Node/BlockTest.php +++ b/tests/Node/BlockTest.php @@ -34,7 +34,7 @@ class BlockTest extends NodeTestCase $tests[] = [new BlockNode('foo', new TextNode('foo', 1), 1), << + * @return iterable */ public function block_foo(array \$context, array \$blocks = []): iterable {