1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Add support for doubly-extended non-template params

This commit is contained in:
Matthew Brown 2019-06-24 23:57:19 -04:00
parent 9d998bf3ac
commit 5cb6fe14d7
2 changed files with 30 additions and 0 deletions

View File

@ -732,6 +732,11 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
$found_generic_params[$type_key][$template_fq_class_name] = [
$found_generic_params[$t->param_name][$t->defining_class ?: ''][0]
];
} else {
$found_generic_params[$type_key][$template_fq_class_name] = [
clone $extended_type
];
break;
}
}
}

View File

@ -2170,6 +2170,31 @@ class TemplateExtendsTest extends TestCase
}
}',
],
'extendsArryObjectGetIterator' => [
'<?php
class Obj {}
/**
* @template T1
* @template-extends ArrayObject<int, T1>
*/
class Collection extends ArrayObject {}
/**
* @template T2 as Obj
* @template-extends Collection<T2>
*/
class Collection2 extends Collection {
/**
* called to get the collection ready when we go to loop through it
*
* @return \ArrayIterator<int, T2>
*/
public function getIterator() {
return parent::getIterator();
}
}'
],
];
}