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:
parent
f81f325c8e
commit
ab22634d23
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user