1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #2445 - only generalise param when it’s generic

This commit is contained in:
Brown 2019-12-09 10:58:09 -05:00
parent 40bdc219ff
commit b78acf796f
2 changed files with 25 additions and 1 deletions

View File

@ -1227,7 +1227,7 @@ class ExpressionAnalyzer
$return_type->value = $static_class_type;
} else {
if ($return_type instanceof Type\Atomic\TGenericObject
&& $static_class_type instanceof Type\Atomic\TNamedObject
&& $static_class_type instanceof Type\Atomic\TGenericObject
) {
$return_type->value = $static_class_type->value;
} else {

View File

@ -2420,6 +2420,30 @@ class ClassTemplateExtendsTest extends TestCase
}
}'
],
'extendsWithMoreTemplateParams' => [
'<?php
/**
* @template T
*/
class Container {
/** @var T */
private $t;
/** @param T $t */
public function __construct($t) {
$this->t = $t;
}
/** @return static<T> */
public function getAnother() {
return clone $this;
}
}
class MyContainer extends Container {}
$a = (new MyContainer("hello"))->getAnother();',
],
];
}