Skip to content

Inline yield in Generator complains about missing return type #3669

@dantleech

Description

@dantleech

PHPStan reports a false positive when inline yield is used:

<?php

function foo(): Generator
{
    while ($bar = yield 'foo') {
    }
}
Function foo() should return Generator but return statement is missing.

https://phpstan.org/r/ec37ffcb-25f5-424a-b21c-2f5ec10703dd

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions