mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Prevent if checking unless we’re in a top-level if
This commit is contained in:
parent
158a2150a7
commit
e1255db32a
@ -438,24 +438,26 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
|
||||
} elseif ($node instanceof PhpParser\Node\Stmt\If_) {
|
||||
$this->skip_if_descendants = false;
|
||||
|
||||
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
|
||||
&& ($node->cond->expr->name->parts === ['function_exists']
|
||||
|| $node->cond->expr->name->parts === ['class_exists']
|
||||
|| $node->cond->expr->name->parts === ['interface_exists']
|
||||
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
|
||||
&& ($node->cond->expr->name->parts === ['function_exists']
|
||||
|| $node->cond->expr->name->parts === ['class_exists']
|
||||
|| $node->cond->expr->name->parts === ['interface_exists']
|
||||
)
|
||||
) {
|
||||
$this->not_exists_cond_expr = $node->cond->expr;
|
||||
}
|
||||
} elseif ($node->cond instanceof PhpParser\Node\Expr\FuncCall
|
||||
&& $node->cond->name instanceof PhpParser\Node\Name
|
||||
&& ($node->cond->name->parts === ['function_exists']
|
||||
|| $node->cond->name->parts === ['class_exists']
|
||||
|| $node->cond->name->parts === ['interface_exists']
|
||||
)
|
||||
) {
|
||||
$this->not_exists_cond_expr = $node->cond->expr;
|
||||
$this->exists_cond_expr = $node->cond;
|
||||
}
|
||||
} elseif ($node->cond instanceof PhpParser\Node\Expr\FuncCall
|
||||
&& $node->cond->name instanceof PhpParser\Node\Name
|
||||
&& ($node->cond->name->parts === ['function_exists']
|
||||
|| $node->cond->name->parts === ['class_exists']
|
||||
|| $node->cond->name->parts === ['interface_exists']
|
||||
)
|
||||
) {
|
||||
$this->exists_cond_expr = $node->cond;
|
||||
}
|
||||
|
||||
if ($this->exists_cond_expr && !$this->enterConditional($this->exists_cond_expr)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user