mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Add tests
This commit is contained in:
parent
95ef63ece9
commit
0220da0b32
@ -235,6 +235,7 @@ class ClassTemplateParamCollector
|
||||
}
|
||||
} else {
|
||||
if ($template_result !== null) {
|
||||
$type_extends_atomic = clone $type_extends_atomic;
|
||||
$type_extends_atomic->replaceTemplateTypesWithArgTypes(
|
||||
$template_result,
|
||||
$codebase
|
||||
|
@ -3764,6 +3764,40 @@ class ClassTemplateTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'complexTypes' => [
|
||||
'code' => '<?php
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class Future {
|
||||
/**
|
||||
* @param T $v
|
||||
*/
|
||||
public function __construct(private $v) {}
|
||||
/** @return T */
|
||||
public function get() { return $this->v; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @template TTObject
|
||||
*
|
||||
* @extends Future<ArrayObject<int, TTObject>>
|
||||
*/
|
||||
class FutureB extends Future {
|
||||
/** @param TTObject $data */
|
||||
public function __construct($data) { parent::__construct(new ArrayObject([$data])); }
|
||||
}
|
||||
|
||||
$a = new FutureB(123);
|
||||
|
||||
$r = $a->get();',
|
||||
'assertions' => [
|
||||
'$a===' => 'FutureB<123>',
|
||||
'$r===' => 'ArrayObject<int, 123>'
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user