Skip to content

Commit

Permalink
Check if argument passed to isset() is not a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitamet committed Jul 31, 2023
1 parent dc81630 commit b7b21cd
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
namespace Psalm\Internal\Analyzer\Statements\Expression;

use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Issue\InvalidArgument;
use Psalm\IssueBuffer;
use Psalm\Type;

/**
Expand All @@ -30,6 +33,17 @@ public static function analyze(
$context->vars_in_scope[$var_id] = Type::getMixed();
$context->vars_possibly_in_scope[$var_id] = true;
}
} elseif (!$isset_var instanceof PhpParser\Node\Expr\PropertyFetch
&& !$isset_var instanceof PhpParser\Node\Expr\Variable
) {
IssueBuffer::maybeAdd(
new InvalidArgument(
'Isset only works with variables',
new CodeLocation($statements_analyzer->getSource(), $isset_var),
'empty',
),
$statements_analyzer->getSuppressedIssues(),
);
}

self::analyzeIssetVar($statements_analyzer, $isset_var, $context);
Expand Down

0 comments on commit b7b21cd

Please sign in to comment.