mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 20:36:33 +00:00
Add return type to compiled macro
This makes it easier for TwigStan to analyze the return type.
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Twig\Node;
|
||||
use Twig\Attribute\YieldReady;
|
||||
use Twig\Compiler;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Markup;
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\Variable\LocalVariable;
|
||||
|
||||
@@ -76,7 +77,7 @@ class MacroNode extends Node
|
||||
|
||||
$compiler
|
||||
->raw('...$varargs')
|
||||
->raw(")\n")
|
||||
->raw("): string|Markup\n")
|
||||
->write("{\n")
|
||||
->indent()
|
||||
->write("\$macros = \$this->macros;\n")
|
||||
|
||||
@@ -49,7 +49,7 @@ class MacroTest extends NodeTestCase
|
||||
|
||||
yield 'with use_yield = true' => [$node, <<<EOF
|
||||
// line 1
|
||||
public function macro_foo(\$foo = null, \$bar = "Foo", ...\$varargs)
|
||||
public function macro_foo(\$foo = null, \$bar = "Foo", ...\$varargs): string|Markup
|
||||
{
|
||||
\$macros = \$this->macros;
|
||||
\$context = [
|
||||
@@ -71,7 +71,7 @@ EOF
|
||||
|
||||
yield 'with use_yield = false' => [$node, <<<EOF
|
||||
// line 1
|
||||
public function macro_foo(\$foo = null, \$bar = "Foo", ...\$varargs)
|
||||
public function macro_foo(\$foo = null, \$bar = "Foo", ...\$varargs): string|Markup
|
||||
{
|
||||
\$macros = \$this->macros;
|
||||
\$context = [
|
||||
|
||||
Reference in New Issue
Block a user