mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #6212 - remove untested code, add test for reasonable behaviour
This commit is contained in:
parent
edffb1a02c
commit
a205a23ccb
@ -1045,20 +1045,16 @@ class CallAnalyzer
|
||||
continue;
|
||||
}
|
||||
|
||||
$equality_classlikes = [];
|
||||
$equality_types = [];
|
||||
$equality_types = array_unique(
|
||||
array_map(
|
||||
function($bound_with_equality) {
|
||||
return $bound_with_equality->type->getId();
|
||||
},
|
||||
$bounds_with_equality
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($bounds_with_equality as $bound_with_equality) {
|
||||
$equality_classlikes[] = $bound_with_equality->equality_bound_classlike;
|
||||
$equality_types[] = $bound_with_equality->type->getId();
|
||||
}
|
||||
|
||||
$equality_classlikes = array_unique($equality_classlikes);
|
||||
$equality_types = array_unique($equality_types);
|
||||
|
||||
if (count($equality_classlikes) > 1
|
||||
|| count($equality_types) > 1
|
||||
) {
|
||||
if (count($equality_types) > 1) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidArgument(
|
||||
'Incompatible types found for ' . $template_name,
|
||||
|
@ -3554,6 +3554,29 @@ class ClassTemplateTest extends TestCase
|
||||
return rand(0, 1) ? $c : $d->get();
|
||||
}',
|
||||
],
|
||||
'allowCompatibleGenerics' => [
|
||||
'<?php
|
||||
/** @template T of object */
|
||||
interface A {}
|
||||
|
||||
/** @template T of object */
|
||||
interface B {}
|
||||
|
||||
/**
|
||||
* @template T of object
|
||||
* @param A<T> $a
|
||||
* @param B<T> $b
|
||||
*/
|
||||
function foo(A $a, B $b): void {}
|
||||
|
||||
/**
|
||||
* @param A<stdClass> $a
|
||||
* @param B<stdClass> $b
|
||||
*/
|
||||
function bar(A $a, B $b): void {
|
||||
foo($a, $b);
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user