1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #485 when return type is a generator

This commit is contained in:
Matthew Brown 2018-02-07 22:29:32 -05:00
parent 1ae58f0386
commit 24e03edefa
2 changed files with 13 additions and 0 deletions

View File

@ -235,6 +235,7 @@ class ReturnChecker
} else {
if ($storage->signature_return_type
&& !$storage->signature_return_type->isVoid()
&& !$storage->signature_return_type->isGenerator()
) {
if (IssueBuffer::accepts(
new InvalidReturnStatement(

View File

@ -271,6 +271,18 @@ class Php70Test extends TestCase
new B();
}',
],
'generatorVoidReturn' => [
'<?php
/**
* @return Generator
*/
function generator2() : Generator {
if (rand(0,1)) {
return;
}
yield 2;
}',
]
];
}