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:
parent
3ade4b9559
commit
23e4c8f68b
@ -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,
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user