mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 12:24:49 +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
|
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
|
&& $nodes
|
||||||
&& ($stmt_expr_type = $nodes->getType($stmt->cond))
|
&& ($stmt_expr_type = $nodes->getType($stmt->cond))
|
||||||
&& $stmt_expr_type->isAlwaysTruthy()
|
&& $stmt_expr_type->isAlwaysTruthy()
|
||||||
|
@ -16,6 +16,14 @@ class DoTest extends TestCase
|
|||||||
public function providerValidCodeParse(): iterable
|
public function providerValidCodeParse(): iterable
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'doWhileTrue' => [
|
||||||
|
'code' => '<?php
|
||||||
|
function ret(): int {
|
||||||
|
do {
|
||||||
|
return 1;
|
||||||
|
} while (true);
|
||||||
|
}'
|
||||||
|
],
|
||||||
'doWhileVar' => [
|
'doWhileVar' => [
|
||||||
'code' => '<?php
|
'code' => '<?php
|
||||||
$worked = false;
|
$worked = false;
|
||||||
|
@ -16,6 +16,14 @@ class ForTest extends TestCase
|
|||||||
public function providerValidCodeParse(): iterable
|
public function providerValidCodeParse(): iterable
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'forTrue' => [
|
||||||
|
'code' => '<?php
|
||||||
|
function ret(): int {
|
||||||
|
for (;;) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
],
|
||||||
'implicitFourthLoop' => [
|
'implicitFourthLoop' => [
|
||||||
'code' => '<?php
|
'code' => '<?php
|
||||||
function test(): int {
|
function test(): int {
|
||||||
|
@ -14,6 +14,14 @@ class WhileTest extends TestCase
|
|||||||
public function providerValidCodeParse(): iterable
|
public function providerValidCodeParse(): iterable
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'whileTrue' => [
|
||||||
|
'code' => '<?php
|
||||||
|
function ret(): int {
|
||||||
|
do {
|
||||||
|
return 1;
|
||||||
|
} while (true);
|
||||||
|
}'
|
||||||
|
],
|
||||||
'whileVar' => [
|
'whileVar' => [
|
||||||
'code' => '<?php
|
'code' => '<?php
|
||||||
$worked = false;
|
$worked = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user