mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 12:24:49 +01:00
Fix #3917 - allow comparisons between classes and interfaces
This commit is contained in:
parent
38af5db8f0
commit
cb243778d2
@ -239,7 +239,7 @@ class ObjectComparator
|
||||
$input_type_is_interface = $codebase->interfaceExists($intersection_input_type_lower);
|
||||
$container_type_is_interface = $codebase->interfaceExists($intersection_container_type_lower);
|
||||
|
||||
if ($allow_interface_equality && $input_type_is_interface && $container_type_is_interface) {
|
||||
if ($allow_interface_equality && $container_type_is_interface) {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,8 @@ class UnionTypeComparator
|
||||
$type2_part,
|
||||
true,
|
||||
false,
|
||||
$first_comparison_result
|
||||
$first_comparison_result,
|
||||
true
|
||||
)
|
||||
&& !$first_comparison_result->to_string_cast
|
||||
) || (AtomicTypeComparator::isContainedBy(
|
||||
@ -437,7 +438,8 @@ class UnionTypeComparator
|
||||
$type1_part,
|
||||
true,
|
||||
false,
|
||||
$second_comparison_result
|
||||
$second_comparison_result,
|
||||
true
|
||||
)
|
||||
&& !$second_comparison_result->to_string_cast
|
||||
) || ($first_comparison_result->type_coerced
|
||||
|
@ -2818,6 +2818,16 @@ class ConditionalTest extends \Psalm\Tests\TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'getClassInterfaceCanBeClass' => [
|
||||
'<?php
|
||||
interface Id {}
|
||||
|
||||
class A {
|
||||
public function is(Id $other): bool {
|
||||
return get_class($this) === get_class($other);
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user