1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00
This commit is contained in:
Daniil Gentili 2022-12-18 18:14:43 +01:00
parent bccda92f31
commit 70d1a5a3c5

View File

@ -16,6 +16,49 @@ class ClassTemplateTest extends TestCase
public function providerValidCodeParse(): iterable public function providerValidCodeParse(): iterable
{ {
return [ 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' => [ 'cachingIterator' => [
'code' => '<?php 'code' => '<?php