mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Don’t overwrite already-defined template
This commit is contained in:
parent
467da32f84
commit
4734583444
@ -2129,8 +2129,10 @@ class CallAnalyzer
|
||||
}
|
||||
}
|
||||
} elseif ($class_storage->template_types) {
|
||||
foreach ($class_storage->template_types as $template_name => $type) {
|
||||
$template_types[$template_name] = $type;
|
||||
foreach ($class_storage->template_types as $template_name => $type_map) {
|
||||
foreach ($type_map as $key => list($type)) {
|
||||
$template_types[$template_name][$key] = [$type];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3329,6 +3329,56 @@ class ClassTemplateExtendsTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'sameNamedTemplateDefinedInParentFunction' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template T2
|
||||
*/
|
||||
class Query {
|
||||
/** @var T2 **/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param T2 $value
|
||||
*/
|
||||
public function __construct($value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
interface Temporal {
|
||||
/**
|
||||
* @template T
|
||||
* @param Query<T> $query
|
||||
*/
|
||||
public function execute(Query $query) : void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class Result implements Temporal {
|
||||
/** @var T **/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param T $value
|
||||
*/
|
||||
public function __construct($value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function execute(Query $query) : void {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Result<string> $result
|
||||
* @param Query<string> $query
|
||||
*/
|
||||
function takesArgs(Result $result, Query $query) : void {
|
||||
$result->execute($query);
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user