1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Use better way to determine which signture to use

Fixes #4524
This commit is contained in:
Matt Brown 2020-11-11 19:22:23 -05:00 committed by Daniil Gentili
parent fb5ee1e46d
commit bd20313a14
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 39 additions and 4 deletions

View File

@ -762,9 +762,7 @@ class Methods
$self_class = $overridden_class_storage->name;
if ($candidate_type
&& $source_analyzer
) {
if ($candidate_type && $source_analyzer && !$candidate_type->isMixed()) {
$old_contained_by_new = UnionTypeComparator::isContainedBy(
$source_analyzer->getCodebase(),
$candidate_type,

View File

@ -311,7 +311,12 @@ class Populator
if ($declaring_method_storage->has_docblock_param_types
&& !$method_storage->has_docblock_param_types
&& !isset($storage->documenting_method_ids[$method_name])
&& (!isset($storage->documenting_method_ids[$method_name])
|| \in_array(
$storage->documenting_method_ids[$method_name]->fq_class_name,
$declaring_class_storage->parent_interfaces
)
)
) {
$storage->documenting_method_ids[$method_name] = $declaring_method_id;
}

View File

@ -4561,6 +4561,38 @@ class ClassTemplateExtendsTest extends TestCase
}
}'
],
'inheritCorrectParams' => [
'<?php
interface ToBeIgnored
{
/**
* @param mixed $value
* @return mixed
*/
public static function of($value);
}
interface ToBeUsed extends ToBeIgnored
{
/**
* @template U
* @param U $value
* @return U
*/
public static function of($value);
}
interface ExtendsToBeUsed extends ToBeUsed {}
class Foo implements ExtendsToBeUsed {
/** @psalm-suppress InvalidReturnType */
public static function of($value) {}
}
function bar(Foo $f, string $s) : string {
return $f::of($s);
}'
],
];
}