Skip to content

Commit 55d2ea8

Browse files
authored
Merge pull request #10 from sasezaki/is_array_on_nested_stmts
is_array on nested stmts
2 parents 6180a99 + 3c7b4ff commit 55d2ea8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/TypedLocalVariableChecker.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Psalm\StatementsSource;
1414
use Psalm\Storage\FunctionLikeStorage;
1515
use Psalm\Type\Union;
16+
use function is_array;
1617

1718
final class TypedLocalVariableChecker implements AfterExpressionAnalysisInterface, AfterFunctionLikeAnalysisInterface
1819
{
@@ -50,11 +51,14 @@ public static function afterStatementAnalysis(
5051
}
5152
}
5253

53-
private static function filterStatementsVar(array $stmts): iterable
54+
/**
55+
* @param PhpParser\Node\Stmt[] $stmts
56+
* @return \Generator<string, array{expr: PhpParser\Node\Expr\Assign, context_var: Union, statements_source: StatementsSource}, null, void>
57+
*/
58+
private static function filterStatementsVar(array $stmts): \Generator
5459
{
55-
5660
foreach ($stmts as $expr) {
57-
if (isset($expr->stmts)) {
61+
if (isset($expr->stmts) && is_array($expr->stmts)) {
5862
yield from self::filterStatementsVar($expr->stmts);
5963
}
6064

0 commit comments

Comments
 (0)