Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for YieldFrom into places where Yield_ is checked #8427

Closed
wants to merge 1 commit into from
Closed

Add support for YieldFrom into places where Yield_ is checked #8427

wants to merge 1 commit into from

Conversation

integer
Copy link

@integer integer commented Jan 25, 2024

I was guided to this change by debugging why AddVoidReturnTypeWhereNoReturnRector generates errors on code like this:

$sheet->method('nextRow')->willReturn((function () {
    yield from  [1, 2, 3];
})());

Output with --dry-run before fix:

 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1 file with changes
===================

1) tests/...shorten..../Test.php:147

    ---------- begin diff ----------
@@ @@
             'sheet without values' => [
                 'sheetCallResult' => self::returnValue((function () use ($sheet) {
                     $sheet = clone $sheet;
-                    $sheet->method('nextRow')->willReturn((function () {
+                    $sheet->method('nextRow')->willReturn((function (): void {
                         yield from [1, 2, 3];
                     })());
                     return $sheet;
    ----------- end diff -----------

Applied rules:
 * AddVoidReturnTypeWhereNoReturnRector

 [OK] 1 file would have changed (dry-run) by Rector

So I add Checking for PhpParser\Node\Expr\YieldFrom into places where more common PhpParser\Node\Expr\Yield_ was checked.

Copy link
Contributor

This repository content is generated by rectorphp/rector-src. Please open pull request to rectorphp/rector-src.

@github-actions github-actions bot closed this Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant