mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #2594 - forbid isset check on null
This commit is contained in:
parent
7b887efc2c
commit
131fb97663
@ -173,9 +173,17 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
|
||||
if (empty($existing_var_type->getAtomicTypes())) {
|
||||
$failed_reconciliation = 2;
|
||||
|
||||
// @todo - I think there's a better way to handle this, but for the moment
|
||||
// mixed will have to do.
|
||||
return Type::getMixed();
|
||||
if (IssueBuffer::accepts(
|
||||
new TypeDoesNotContainType(
|
||||
'Cannot resolve types for ' . $key . ' on null var',
|
||||
$code_location
|
||||
),
|
||||
$suppressed_issues
|
||||
)) {
|
||||
// fall through
|
||||
}
|
||||
|
||||
return Type::getEmpty();
|
||||
}
|
||||
|
||||
if ($existing_var_type->hasType('empty')) {
|
||||
|
@ -778,6 +778,15 @@ class IssetTest extends \Psalm\Tests\TestCase
|
||||
}',
|
||||
'error_message' => 'UndefinedVariable'
|
||||
],
|
||||
'issetNullVar' => [
|
||||
'<?php
|
||||
function four(?string $s) : void {
|
||||
if ($s === null) {
|
||||
if (isset($s)) {}
|
||||
}
|
||||
}',
|
||||
'error_message' => 'TypeDoesNotContainType',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user