Skip to content

Commit

Permalink
Fix type for property-get with null-coalesce
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonE committed Nov 9, 2024
1 parent 3340657 commit c0672fe
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Internal\Analyzer\Statements\Expression\Fetch\InstancePropertyFetchAnalyzer;
use Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Issue\InvalidArgument;
Expand All @@ -30,7 +31,16 @@ public static function analyze(
$var_id = '$this->' . $isset_var->name->name;

if (!isset($context->vars_in_scope[$var_id])) {
$context->vars_in_scope[$var_id] = Type::getMixed();
if (isset($context->vars_in_scope['$this'])) {
InstancePropertyFetchAnalyzer::analyze(
$statements_analyzer,
$isset_var,
$context,
);
}
if (!isset($context->vars_in_scope[$var_id])) {
$context->vars_in_scope[$var_id] = Type::getMixed();
}
$context->vars_possibly_in_scope[$var_id] = true;
}
} elseif (!self::isValidStatement($isset_var)) {
Expand Down

0 comments on commit c0672fe

Please sign in to comment.