From 472c2839ad73099929460fb2c5932f959aba1bdf Mon Sep 17 00:00:00 2001 From: Brown Date: Tue, 1 Sep 2020 00:12:12 -0400 Subject: [PATCH] Fix crash with `@var` over `echo` --- src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php | 1 + tests/AnnotationTest.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php index 6d8d15365..8b8f78f85 100644 --- a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php @@ -451,6 +451,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse || $node instanceof PhpParser\Node\Stmt\Foreach_ || $node instanceof PhpParser\Node\Stmt\While_ || $node instanceof PhpParser\Node\Stmt\Do_ + || $node instanceof PhpParser\Node\Stmt\Echo_ ) { if ($doc_comment = $node->getDocComment()) { $var_comments = []; diff --git a/tests/AnnotationTest.php b/tests/AnnotationTest.php index 6ccb631a2..6a811e2e0 100644 --- a/tests/AnnotationTest.php +++ b/tests/AnnotationTest.php @@ -1168,6 +1168,11 @@ class AnnotationTest extends TestCase function takesString(string $s): void {}' ], + 'noCrashWithoutAssignment' => [ + 'format("Y");' + ], ]; }