mirror of
https://github.com/danog/psalm.git
synced 2024-11-29 20:28:59 +01:00
Fix #8923
This commit is contained in:
parent
7d95f15e30
commit
2f5d0a4a9f
@ -265,7 +265,8 @@ class ScopeAnalyzer
|
||||
static fn(string $action): bool => $action !== self::ACTION_NONE
|
||||
);
|
||||
|
||||
if ($stmt instanceof PhpParser\Node\Stmt\While_
|
||||
if (($stmt instanceof PhpParser\Node\Stmt\While_
|
||||
|| $stmt instanceof PhpParser\Node\Stmt\Do_)
|
||||
&& $nodes
|
||||
&& ($stmt_expr_type = $nodes->getType($stmt->cond))
|
||||
&& $stmt_expr_type->isAlwaysTruthy()
|
||||
|
@ -16,6 +16,14 @@ class DoTest extends TestCase
|
||||
public function providerValidCodeParse(): iterable
|
||||
{
|
||||
return [
|
||||
'doWhileTrue' => [
|
||||
'code' => '<?php
|
||||
function ret(): int {
|
||||
do {
|
||||
return 1;
|
||||
} while (true);
|
||||
}'
|
||||
],
|
||||
'doWhileVar' => [
|
||||
'code' => '<?php
|
||||
$worked = false;
|
||||
|
@ -16,6 +16,14 @@ class ForTest extends TestCase
|
||||
public function providerValidCodeParse(): iterable
|
||||
{
|
||||
return [
|
||||
'forTrue' => [
|
||||
'code' => '<?php
|
||||
function ret(): int {
|
||||
for (;;) {
|
||||
return 1;
|
||||
}
|
||||
}'
|
||||
],
|
||||
'implicitFourthLoop' => [
|
||||
'code' => '<?php
|
||||
function test(): int {
|
||||
|
@ -14,6 +14,14 @@ class WhileTest extends TestCase
|
||||
public function providerValidCodeParse(): iterable
|
||||
{
|
||||
return [
|
||||
'whileTrue' => [
|
||||
'code' => '<?php
|
||||
function ret(): int {
|
||||
do {
|
||||
return 1;
|
||||
} while (true);
|
||||
}'
|
||||
],
|
||||
'whileVar' => [
|
||||
'code' => '<?php
|
||||
$worked = false;
|
||||
|
Loading…
Reference in New Issue
Block a user