File tree Expand file tree Collapse file tree 4 files changed +26
-1
lines changed
src/Psalm/Internal/Analyzer Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,8 @@ public static function getControlActions(
265265 static fn (string $ action ): bool => $ action !== self ::ACTION_NONE
266266 );
267267
268- if ($ stmt instanceof PhpParser \Node \Stmt \While_
268+ if (($ stmt instanceof PhpParser \Node \Stmt \While_
269+ || $ stmt instanceof PhpParser \Node \Stmt \Do_)
269270 && $ nodes
270271 && ($ stmt_expr_type = $ nodes ->getType ($ stmt ->cond ))
271272 && $ stmt_expr_type ->isAlwaysTruthy ()
Original file line number Diff line number Diff line change @@ -16,6 +16,14 @@ class DoTest extends TestCase
1616 public function providerValidCodeParse (): iterable
1717 {
1818 return [
19+ 'doWhileTrue ' => [
20+ 'code ' => '<?php
21+ function ret(): int {
22+ do {
23+ return 1;
24+ } while (true);
25+ } '
26+ ],
1927 'doWhileVar ' => [
2028 'code ' => '<?php
2129 $worked = false;
Original file line number Diff line number Diff line change @@ -16,6 +16,14 @@ class ForTest extends TestCase
1616 public function providerValidCodeParse (): iterable
1717 {
1818 return [
19+ 'forTrue ' => [
20+ 'code ' => '<?php
21+ function ret(): int {
22+ for (;;) {
23+ return 1;
24+ }
25+ } '
26+ ],
1927 'implicitFourthLoop ' => [
2028 'code ' => '<?php
2129 function test(): int {
Original file line number Diff line number Diff line change @@ -14,6 +14,14 @@ class WhileTest extends TestCase
1414 public function providerValidCodeParse (): iterable
1515 {
1616 return [
17+ 'whileTrue ' => [
18+ 'code ' => '<?php
19+ function ret(): int {
20+ do {
21+ return 1;
22+ } while (true);
23+ } '
24+ ],
1725 'whileVar ' => [
1826 'code ' => '<?php
1927 $worked = false;
You can’t perform that action at this time.
0 commit comments