mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix #4958 - honour template as inheritance when comparing template types
This commit is contained in:
parent
387abc1cb6
commit
99da1daae5
@ -73,15 +73,24 @@ class ObjectComparator
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\substr($intersection_container_type->defining_class, 0, 3) === 'fn-') {
|
foreach ($intersection_input_types as $intersection_input_type) {
|
||||||
foreach ($intersection_input_types as $intersection_input_type) {
|
if ($intersection_input_type instanceof TTemplateParam
|
||||||
if ($intersection_input_type instanceof TTemplateParam
|
&& (\substr($intersection_container_type->defining_class, 0, 3) === 'fn-'
|
||||||
&& \substr($intersection_input_type->defining_class, 0, 3) === 'fn-'
|
|| \substr($intersection_input_type->defining_class, 0, 3) === 'fn-')
|
||||||
|
) {
|
||||||
|
if (\substr($intersection_input_type->defining_class, 0, 3) === 'fn-'
|
||||||
|
&& \substr($intersection_container_type->defining_class, 0, 3) === 'fn-'
|
||||||
&& $intersection_input_type->defining_class
|
&& $intersection_input_type->defining_class
|
||||||
!== $intersection_container_type->defining_class
|
!== $intersection_container_type->defining_class
|
||||||
) {
|
) {
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($intersection_input_type->as->getAtomicTypes() as $input_as_atomic) {
|
||||||
|
if ($input_as_atomic->equals($intersection_container_type)) {
|
||||||
|
continue 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1485,6 +1485,29 @@ class FunctionTemplateTest extends TestCase
|
|||||||
[],
|
[],
|
||||||
'8.0'
|
'8.0'
|
||||||
],
|
],
|
||||||
|
'templateChildClass' => [
|
||||||
|
'<?php
|
||||||
|
/** @template T */
|
||||||
|
class Collection {
|
||||||
|
/**
|
||||||
|
* @param T $t
|
||||||
|
*/
|
||||||
|
private function add($t) : void {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template TChild as T
|
||||||
|
* @param TChild $default
|
||||||
|
*
|
||||||
|
* @return TChild
|
||||||
|
*/
|
||||||
|
public function get($default)
|
||||||
|
{
|
||||||
|
$this->add($default);
|
||||||
|
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user