1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Add tests

This commit is contained in:
Daniil Gentili 2022-08-17 13:30:36 +02:00
parent 95ef63ece9
commit 0220da0b32
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 35 additions and 0 deletions

View File

@ -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

View File

@ -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>'
]
]
];
}