diff --git a/src/Psalm/Checker/MethodChecker.php b/src/Psalm/Checker/MethodChecker.php index e36888cf3..7e485d45c 100644 --- a/src/Psalm/Checker/MethodChecker.php +++ b/src/Psalm/Checker/MethodChecker.php @@ -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; } } diff --git a/src/Psalm/Stubs/CoreGenericClasses.php b/src/Psalm/Stubs/CoreGenericClasses.php index 8df17929a..1b2e36cfc 100644 --- a/src/Psalm/Stubs/CoreGenericClasses.php +++ b/src/Psalm/Stubs/CoreGenericClasses.php @@ -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 + * @template-extends Traversable */ 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 + * @template-extends Traversable */ interface Iterator extends Traversable {