Automattic / phpcs-neutron-standard

A set of phpcs sniffs for PHP >7 development
MIT License
94 stars 7 forks source link

`UnusedReturnType` for `Generator` #71

Closed Hywan closed 4 years ago

Hywan commented 5 years ago

Howdy!

This code:

function f(): Generator {
    yield 42;
}

will throw this error: PHPCS.E.NeutronStandard.Functions.TypeHint.UnusedReturnType saying:

Return type with no return

Yes, there is no return statement, but we have a yield ;-).

Hywan commented 5 years ago

I guess a similar issue will happen when we use iterable instead of Generator.