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

Fix docblock overriden method return type

This commit is contained in:
Matthew Brown 2018-02-01 09:24:57 -05:00
parent d8fb14e6f7
commit 08c1d65ad2
2 changed files with 16 additions and 3 deletions

View File

@ -114,9 +114,19 @@ class MethodChecker extends FunctionLikeChecker
$overridden_class_storage =
$project_checker->classlike_storage_provider->get($fq_overridden_class);
$overridden_return_type = clone $overridden_storage->return_type;
if ($overridden_class_storage->template_types) {
$generic_types = [];
$overridden_return_type->replaceTemplateTypesWithStandins(
$overridden_class_storage->template_types,
$generic_types
);
}
$self_class = $overridden_class_storage->name;
return clone $overridden_storage->return_type;
return $overridden_return_type;
}
}

View File

@ -4,6 +4,7 @@
* Interface to detect if a class is traversable using &foreach;.
* @link http://php.net/manual/en/class.traversable.php
*
* @template TKey
* @template TValue
*/
interface Traversable {
@ -13,9 +14,10 @@ interface Traversable {
* Interface to create an external Iterator.
* @link http://php.net/manual/en/class.iteratoraggregate.php
*
* @template TKey
* @template TValue
*
* @template-extends Traversable<TValue>
* @template-extends Traversable<TKey, TValue>
*/
interface IteratorAggregate extends Traversable {
@ -34,9 +36,10 @@ interface IteratorAggregate extends Traversable {
* themselves internally.
* @link http://php.net/manual/en/class.iterator.php
*
* @template TKey
* @template TValue
*
* @template-extends Traversable<TValue>
* @template-extends Traversable<TKey, TValue>
*/
interface Iterator extends Traversable {