1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #1274 - fix parent:: call to templated method

This commit is contained in:
Matthew Brown 2019-02-04 00:52:31 -05:00
parent f81f325c8e
commit ab22634d23
2 changed files with 46 additions and 0 deletions

View File

@ -646,6 +646,19 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
// fall through
}
$found_generic_params = MethodCallAnalyzer::getClassTemplateParams(
$codebase,
$class_storage,
$stmt->class instanceof PhpParser\Node\Name
&& $stmt->class->parts === ['parent']
&& $context->self
? $context->self
: $fq_class_name,
$method_name_lc,
$lhs_type_part,
null
);
if (self::checkMethodArgs(
$method_id,
$args,

View File

@ -1057,6 +1057,39 @@ class TemplateExtendsTest extends TestCase
}
}',
],
'extendsAndCallsParent' => [
'<?php
/**
* @template T
*/
abstract class Foo
{
/**
* @param T::class $str
*
* @return T::class
*/
public static function DoThing(string $str)
{
return $str;
}
}
/**
* @template-extends Foo<DateTimeInterface>
*/
class Bar extends Foo
{
/**
* @param class-string<DateTimeInterface> $str
*
* @return class-string<DateTimeInterface>
*/
public static function DoThing(string $str)
{
return parent::DoThing($str);
}
}'
],
];
}