Skip to content

Generator::send in infinite loop #10054

@MartkCz

Description

@MartkCz

Bug report

For this code reports "While loop condition is always true.". It's true, but it's not a wrong code.

function falsePositive(): Generator {
	while (true) {
		$item = yield;

		yield $item;
	}
}

$generator = falsePositive();

var_dump($generator->send('foo'));

Code snippet that reproduces the problem

https://phpstan.org/r/25d4a2ba-ac56-46d1-afa0-8fe581926bad

Expected output

No error

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions