Skip to content
Permalink
Browse files

Fix #2569 - improve template return type checks

  • Loading branch information
muglug committed Jan 8, 2020
1 parent adfb488 commit 146dd461ef6f5c36b3c02bf096427da8b85c80f1
Showing with 28 additions and 7 deletions.
  1. +3 −7 src/Psalm/Internal/Analyzer/TypeAnalyzer.php
  2. +25 −0 tests/Template/ClassTemplateExtendsTest.php
@@ -1877,10 +1877,6 @@ private static function isMatchingTypeContainedBy(
$input_type_part->value,
$generic_params
);

if ($container_type_part instanceof TGenericObject) {
$container_type_part->remapped_params = false;
}
}
}

@@ -1913,15 +1909,15 @@ private static function isMatchingTypeContainedBy(

if ($input_type_part->value !== $container_type_part->value
&& $input_class_storage
&& (!$container_type_part instanceof TGenericObject
|| !$container_type_part->remapped_params)
) {
$input_template_types = $input_class_storage->template_types;
$i = 0;

$replacement_templates = [];

if ($input_template_types) {
if ($input_template_types
&& (!$input_type_part instanceof TGenericObject || !$input_type_part->remapped_params)
) {
foreach ($input_template_types as $template_name => $_) {
if (!isset($input_type_params[$i])) {
break;
@@ -2760,6 +2760,31 @@ class SelectIterator implements \Iterator
{
}'
],
'extendWithExtraParam' => [
'<?php
/**
* @template Tk of array-key
* @template Tv
*/
interface ICollection {
/**
* @psalm-return ICollection<Tk, Tv>
*/
public function slice(int $start, int $length): ICollection;
}
/**
* @template T
*
* @extends ICollection<int, T>
*/
interface IVector extends ICollection {
/**
* @psalm-return IVector<T>
*/
public function slice(int $start, int $length): ICollection;
}'
]
];
}

0 comments on commit 146dd46

Please sign in to comment.
You can’t perform that action at this time.