mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #3894 - don’t alter class-string during erroneous emptiness check
This commit is contained in:
parent
3f06d4f706
commit
1d077cc48e
@ -644,7 +644,10 @@ class SimpleNegatedAssertionReconciler extends Reconciler
|
||||
}
|
||||
|
||||
if (isset($existing_var_atomic_types['string'])) {
|
||||
if (!$existing_var_atomic_types['string'] instanceof Type\Atomic\TNonEmptyString) {
|
||||
if (!$existing_var_atomic_types['string'] instanceof Type\Atomic\TNonEmptyString
|
||||
&& !$existing_var_atomic_types['string'] instanceof Type\Atomic\TClassString
|
||||
&& !$existing_var_atomic_types['string'] instanceof Type\Atomic\GetClassT
|
||||
) {
|
||||
$did_remove_type = true;
|
||||
|
||||
$existing_var_type->removeType('string');
|
||||
|
@ -1341,6 +1341,14 @@ class RedundantConditionTest extends \Psalm\Tests\TestCase
|
||||
if ($a && $a instanceof A) {}',
|
||||
'error_message' => 'RedundantConditionGivenDocblockType',
|
||||
],
|
||||
'classStringNotEmpty' => [
|
||||
'<?php
|
||||
function foo(object $o) : void {
|
||||
$oc = get_class($o);
|
||||
if ($oc) {}
|
||||
}',
|
||||
'error_message' => 'RedundantCondition',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user