1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Prevent if checking unless we’re in a top-level if

This commit is contained in:
Matthew Brown 2019-06-10 00:02:36 -04:00
parent 158a2150a7
commit e1255db32a

View File

@ -438,6 +438,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
} elseif ($node instanceof PhpParser\Node\Stmt\If_) {
$this->skip_if_descendants = false;
if (!$this->fq_classlike_names && !$this->functionlike_storages) {
if ($node->cond instanceof PhpParser\Node\Expr\BooleanNot) {
if ($node->cond->expr instanceof PhpParser\Node\Expr\FuncCall
&& $node->cond->expr->name instanceof PhpParser\Node\Name
@ -457,6 +458,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
) {
$this->exists_cond_expr = $node->cond;
}
}
if ($this->exists_cond_expr && !$this->enterConditional($this->exists_cond_expr)) {
$this->skip_if_descendants = true;