mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
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.
This commit is contained in:
@@ -33,7 +33,7 @@ class BlockNode extends Node
|
|||||||
$compiler
|
$compiler
|
||||||
->addDebugInfo($this)
|
->addDebugInfo($this)
|
||||||
->write("/**\n")
|
->write("/**\n")
|
||||||
->write(" * @return iterable<string>\n")
|
->write(" * @return iterable<null|scalar|\Stringable>\n")
|
||||||
->write(" */\n")
|
->write(" */\n")
|
||||||
->write(\sprintf("public function block_%s(array \$context, array \$blocks = []): iterable\n", $this->getAttribute('name')), "{\n")
|
->write(\sprintf("public function block_%s(array \$context, array \$blocks = []): iterable\n", $this->getAttribute('name')), "{\n")
|
||||||
->indent()
|
->indent()
|
||||||
|
|||||||
+4
-4
@@ -382,7 +382,7 @@ abstract class Template
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return iterable<string>
|
* @return iterable<null|scalar|\Stringable>
|
||||||
*/
|
*/
|
||||||
public function yield(array $context, array $blocks = []): iterable
|
public function yield(array $context, array $blocks = []): iterable
|
||||||
{
|
{
|
||||||
@@ -412,7 +412,7 @@ abstract class Template
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return iterable<string>
|
* @return iterable<null|scalar|\Stringable>
|
||||||
*/
|
*/
|
||||||
public function yieldBlock($name, array $context, array $blocks = [], $useBlocks = true, ?self $templateContext = null): 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 $context The context
|
||||||
* @param array $blocks The current set of blocks
|
* @param array $blocks The current set of blocks
|
||||||
*
|
*
|
||||||
* @return iterable<string>
|
* @return iterable<null|scalar|\Stringable>
|
||||||
*/
|
*/
|
||||||
public function yieldParentBlock($name, array $context, array $blocks = []): 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 $context An array of parameters to pass to the template
|
||||||
* @param array $blocks An array of blocks to pass to the template
|
* @param array $blocks An array of blocks to pass to the template
|
||||||
*
|
*
|
||||||
* @return iterable<string>
|
* @return iterable<null|scalar|\Stringable>
|
||||||
*/
|
*/
|
||||||
abstract protected function doDisplay(array $context, array $blocks = []): iterable;
|
abstract protected function doDisplay(array $context, array $blocks = []): iterable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class BlockTest extends NodeTestCase
|
|||||||
$tests[] = [new BlockNode('foo', new TextNode('foo', 1), 1), <<<EOF
|
$tests[] = [new BlockNode('foo', new TextNode('foo', 1), 1), <<<EOF
|
||||||
// line 1
|
// line 1
|
||||||
/**
|
/**
|
||||||
* @return iterable<string>
|
* @return iterable<null|scalar|\Stringable>
|
||||||
*/
|
*/
|
||||||
public function block_foo(array \$context, array \$blocks = []): iterable
|
public function block_foo(array \$context, array \$blocks = []): iterable
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user