1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #290 - check for yields in assignments

This commit is contained in:
Matthew Brown 2017-11-14 22:08:15 -05:00
parent 3ade4b9559
commit 23e4c8f68b
2 changed files with 16 additions and 0 deletions

View File

@ -51,6 +51,11 @@ class EffectsAnalyser
}
} elseif ($stmt instanceof PhpParser\Node\Expr\Yield_ || $stmt instanceof PhpParser\Node\Expr\YieldFrom) {
$yield_types = array_merge($yield_types, self::getYieldTypeFromExpression($stmt));
} elseif ($stmt instanceof PhpParser\Node\Expr\Assign) {
$return_types = array_merge(
$return_types,
self::getReturnTypes([$stmt->expr], $yield_types, $ignore_nullable_issues)
);
} elseif ($stmt instanceof PhpParser\Node\Stmt\If_) {
$return_types = array_merge(
$return_types,

View File

@ -236,6 +236,17 @@ class Php70Test extends TestCase
],
'error_levels' => ['MixedAssignment'],
],
'generatorWithNestedYield' => [
'<?php
function other_generator() : Generator {
yield "traffic";
return 1;
}
function foo() : Generator {
$value = yield from other_generator();
var_export($value);
}',
],
'multipleUse' => [
'<?php
namespace Name\Space {