1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Prevent features pre-php-8

This commit is contained in:
Matt Brown 2020-10-14 17:09:56 -04:00 committed by Daniil Gentili
parent 66e40f1007
commit 0f8b017384
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 10 additions and 5 deletions

View File

@ -367,16 +367,21 @@ class ExpressionAnalyzer
return Expression\YieldFromAnalyzer::analyze($statements_analyzer, $stmt, $context);
}
if ($stmt instanceof PhpParser\Node\Expr\Match_) {
if ($stmt instanceof PhpParser\Node\Expr\Match_
&& $statements_analyzer->getCodebase()->php_major_version >= 8
) {
return Expression\MatchAnalyzer::analyze($statements_analyzer, $stmt, $context);
}
if ($stmt instanceof PhpParser\Node\Expr\Throw_) {
if ($stmt instanceof PhpParser\Node\Expr\Throw_
&& $statements_analyzer->getCodebase()->php_major_version >= 8
) {
return ThrowAnalyzer::analyze($statements_analyzer, $stmt, $context);
}
if ($stmt instanceof PhpParser\Node\Expr\NullsafePropertyFetch
|| $stmt instanceof PhpParser\Node\Expr\NullsafeMethodCall
if (($stmt instanceof PhpParser\Node\Expr\NullsafePropertyFetch
|| $stmt instanceof PhpParser\Node\Expr\NullsafeMethodCall)
&& $statements_analyzer->getCodebase()->php_major_version >= 8
) {
return Expression\NullsafeAnalyzer::analyze($statements_analyzer, $stmt, $context);
}

View File

@ -2831,7 +2831,7 @@ class ConditionalTest extends \Psalm\Tests\TestCase
) {}
}
function skipOn(IntLinkedList $l) : ?int {
function skipOne(IntLinkedList $l) : ?int {
return $l->next?->value;
}