mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Prevent LessSpecificImplementedReturnType with extended template
This commit is contained in:
parent
811cc08948
commit
2fa0f27872
@ -645,6 +645,11 @@ class MethodAnalyzer extends FunctionLikeAnalyzer
|
||||
}
|
||||
}
|
||||
|
||||
$implementer_method_storage_return_type->replaceTemplateTypesWithArgTypes(
|
||||
$template_types,
|
||||
$codebase
|
||||
);
|
||||
|
||||
$guide_method_storage_return_type->replaceTemplateTypesWithArgTypes(
|
||||
$template_types,
|
||||
$codebase
|
||||
|
@ -1886,6 +1886,24 @@ class TemplateExtendsTest extends TestCase
|
||||
*/
|
||||
class Bar extends Foo {}'
|
||||
],
|
||||
'implementsArrayReturnTypeWithTemplate' => [
|
||||
'<?php
|
||||
/** @template T as mixed */
|
||||
interface I {
|
||||
/**
|
||||
* @param T $v
|
||||
* @return array<string,T>
|
||||
*/
|
||||
public function indexById($v): array;
|
||||
}
|
||||
|
||||
/** @template-implements I<int> */
|
||||
class C implements I {
|
||||
public function indexById($v): array {
|
||||
return [(string)$v => $v];
|
||||
}
|
||||
}',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user