mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 12:24:49 +01:00
Add test
This commit is contained in:
parent
bccda92f31
commit
70d1a5a3c5
@ -16,6 +16,49 @@ class ClassTemplateTest extends TestCase
|
||||
public function providerValidCodeParse(): iterable
|
||||
{
|
||||
return [
|
||||
'templateIntersection' => [
|
||||
'code' => '<?php
|
||||
interface EntityInterface
|
||||
{
|
||||
public function getId(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-template T of EntityInterface
|
||||
*/
|
||||
interface RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @return T|null
|
||||
*/
|
||||
public function byId(string $id);
|
||||
}
|
||||
|
||||
final class Foo implements EntityInterface
|
||||
{
|
||||
public function getId(): string
|
||||
{
|
||||
return "42";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-implements RepositoryInterface<Foo>
|
||||
*/
|
||||
final class FooRepository implements RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @var Foo[]
|
||||
*/
|
||||
public array $elements = [];
|
||||
|
||||
public function byId(string $id): ?Foo
|
||||
{
|
||||
return $this->elements[$id] ?? null;
|
||||
}
|
||||
}
|
||||
'
|
||||
],
|
||||
'cachingIterator' => [
|
||||
'code' => '<?php
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user