Replace return; yield with yield from []

See #4259
This commit is contained in:
Ruud Kamphuis
2024-09-26 16:07:09 +02:00
parent 4dd20ba005
commit 317c69d0ff
3 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ class ForNode extends Node
$compiler->write("\$context = array_intersect_key(\$context, \$$parentVar) + \$$parentVar;\n");
$compiler
->write("return; yield;\n")
->write("yield from [];\n")
->outdent()
->write("};\n")
->write("\Closure::bind(\$$functionVar, \$this, self::class);\n")
+1 -1
View File
@@ -35,7 +35,7 @@
--DATA--
return [
'empty_it' => new \EmptyIterator(),
'yielding_it' => (function (): \Generator { return; yield; })(),
'yielding_it' => (function (): \Generator { yield from []; })(),
]
--EXPECT--
OK
+5 -5
View File
@@ -76,7 +76,7 @@ class ForTest extends NodeTestCase
}
unset(\$context['key'], \$context['item']);
\$context = array_intersect_key(\$context, \$__internal_compile_2) + \$__internal_compile_2;
return; yield;
yield from [];
};
\Closure::bind(\$__internal_compile_1, \$this, self::class);
yield from \$__internal_compile_1(\$__internal_compile_0, \$context, \$blocks, \$__internal_compile_1, 0);
@@ -103,7 +103,7 @@ EOF
}
unset(\$context['k'], \$context['v'], \$context['loop']);
\$context = array_intersect_key(\$context, \$__internal_compile_2) + \$__internal_compile_2;
return; yield;
yield from [];
};
\Closure::bind(\$__internal_compile_1, \$this, self::class);
yield from \$__internal_compile_1(\$__internal_compile_0, \$context, \$blocks, \$__internal_compile_1, 0);
@@ -130,7 +130,7 @@ EOF
}
unset(\$context['k'], \$context['v'], \$context['loop']);
\$context = array_intersect_key(\$context, \$__internal_compile_2) + \$__internal_compile_2;
return; yield;
yield from [];
};
\Closure::bind(\$__internal_compile_1, \$this, self::class);
yield from \$__internal_compile_1(\$__internal_compile_0, \$context, \$blocks, \$__internal_compile_1, 0);
@@ -163,7 +163,7 @@ EOF
}
unset(\$context['k'], \$context['v'], \$context['loop']);
\$context = array_intersect_key(\$context, \$__internal_compile_2) + \$__internal_compile_2;
return; yield;
yield from [];
};
\Closure::bind(\$__internal_compile_1, \$this, self::class);
yield from \$__internal_compile_1(\$__internal_compile_0, \$context, \$blocks, \$__internal_compile_1, 0);
@@ -186,7 +186,7 @@ EOF
}
unset(\$context['_key'], \$context['item'], \$context['loop']);
\$context = array_intersect_key(\$context, \$__internal_compile_2) + \$__internal_compile_2;
return; yield;
yield from [];
};
\Closure::bind(\$__internal_compile_1, \$this, self::class);
yield from \$__internal_compile_1(\$__internal_compile_0, \$context, \$blocks, \$__internal_compile_1, 0);