diff --git a/src/Psalm/Visitor/DependencyFinderVisitor.php b/src/Psalm/Visitor/DependencyFinderVisitor.php index a52254ac6..b7f7e3564 100644 --- a/src/Psalm/Visitor/DependencyFinderVisitor.php +++ b/src/Psalm/Visitor/DependencyFinderVisitor.php @@ -448,7 +448,7 @@ class DependencyFinderVisitor extends PhpParser\NodeVisitorAbstract implements P } } } - } elseif ($node instanceof PhpParser\Node\Expr\Yield_) { + } elseif ($node instanceof PhpParser\Node\Expr\Yield_ || $node instanceof PhpParser\Node\Expr\YieldFrom) { $function_like_storage = end($this->functionlike_storages); if ($function_like_storage) { diff --git a/tests/Php70Test.php b/tests/Php70Test.php index 0dbf26e3f..518521072 100644 --- a/tests/Php70Test.php +++ b/tests/Php70Test.php @@ -323,6 +323,13 @@ class Php70Test extends TestCase takesString($s); }', ], + 'expectNonNullableTypeWithYield' => [ + ' 'InvalidReturnStatement', ], + 'expectNonNullableTypeWithNullReturn' => [ + ' 'NullableReturnStatement', + ], ]; } }