Skip to content

Commit

Permalink
display PHP version when not understanding an expression (#5268)
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah authored Feb 22, 2021
1 parent 61c4bed commit 69eb8e4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,20 @@ private static function handleExpression(
return Expression\YieldFromAnalyzer::analyze($statements_analyzer, $stmt, $context);
}

if ($stmt instanceof PhpParser\Node\Expr\Match_
&& $statements_analyzer->getCodebase()->php_major_version >= 8
) {
$php_major_version = $statements_analyzer->getCodebase()->php_major_version;
$php_minor_version = $statements_analyzer->getCodebase()->php_minor_version;

if ($stmt instanceof PhpParser\Node\Expr\Match_ && $php_major_version >= 8) {
return Expression\MatchAnalyzer::analyze($statements_analyzer, $stmt, $context);
}

if ($stmt instanceof PhpParser\Node\Expr\Throw_
&& $statements_analyzer->getCodebase()->php_major_version >= 8
) {
if ($stmt instanceof PhpParser\Node\Expr\Throw_ && $php_major_version >= 8) {
return ThrowAnalyzer::analyze($statements_analyzer, $stmt, $context);
}

if (($stmt instanceof PhpParser\Node\Expr\NullsafePropertyFetch
|| $stmt instanceof PhpParser\Node\Expr\NullsafeMethodCall)
&& $statements_analyzer->getCodebase()->php_major_version >= 8
&& $php_major_version >= 8
) {
return Expression\NullsafeAnalyzer::analyze($statements_analyzer, $stmt, $context);
}
Expand All @@ -397,7 +396,8 @@ private static function handleExpression(

if (IssueBuffer::accepts(
new UnrecognizedExpression(
'Psalm does not understand ' . get_class($stmt),
'Psalm does not understand ' . get_class($stmt) . ' for PHP ' .
$php_major_version . ' ' . $php_minor_version,
new CodeLocation($statements_analyzer->getSource(), $stmt)
),
$statements_analyzer->getSuppressedIssues()
Expand Down

0 comments on commit 69eb8e4

Please sign in to comment.