Fork me on GitHub
a Sensio Labs Product

Jump & Run (v3.28.0) edition

Rule return_to_yield_from

If the function explicitly returns an array, and has the return type iterable, then yield from must be used instead of return.

Examples

Example #1

--- Original
+++ New
 <?php function giveMeData(): iterable {
-    return [1, 2, 3];
+    yield from [1, 2, 3];
 }
The logo is © 2010-2022 Sensio Labs