mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Move misplaced tests
This commit is contained in:
parent
69b05f5052
commit
fe5138f1a6
@ -1961,6 +1961,79 @@ class TemplateExtendsTest extends TestCase
|
||||
|
||||
foreach ($bat as $num) {}',
|
||||
],
|
||||
'implictIteratorTemplating' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template-implements IteratorAggregate<int, int>
|
||||
*/
|
||||
class SomeIterator implements IteratorAggregate
|
||||
{
|
||||
function getIterator()
|
||||
{
|
||||
yield 1;
|
||||
}
|
||||
}
|
||||
|
||||
/** @param \IteratorAggregate<mixed, int> $i */
|
||||
function takesIteratorOfInts(\IteratorAggregate $i) : void {
|
||||
foreach ($i as $j) {
|
||||
echo $j;
|
||||
}
|
||||
}
|
||||
|
||||
takesIteratorOfInts(new SomeIterator());',
|
||||
],
|
||||
'genericInterface' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template T as object
|
||||
* @param class-string<T> $t
|
||||
* @return T
|
||||
*/
|
||||
function generic(string $t) {
|
||||
return f($t)->get();
|
||||
}
|
||||
|
||||
/** @template T as object */
|
||||
interface I {
|
||||
/** @return T */
|
||||
public function get() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T as object
|
||||
* @template-implements I<T>
|
||||
*/
|
||||
class C implements I {
|
||||
/**
|
||||
* @var T
|
||||
*/
|
||||
public $t;
|
||||
|
||||
/**
|
||||
* @param T $t
|
||||
*/
|
||||
public function __construct(object $t) {
|
||||
$this->t = $t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return T
|
||||
*/
|
||||
public function get() {
|
||||
return $this->t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T as object
|
||||
* @param class-string<T> $t
|
||||
* @return I<T>
|
||||
*/
|
||||
function f(string $t) {
|
||||
return new C(new $t);
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -763,28 +763,6 @@ class TemplateTest extends TestCase
|
||||
|
||||
foreach ($c->getIterator() as $k => $v) { atan($v); strlen($k); }',
|
||||
],
|
||||
'implictIteratorTemplating' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template-implements IteratorAggregate<int, int>
|
||||
*/
|
||||
class SomeIterator implements IteratorAggregate
|
||||
{
|
||||
function getIterator()
|
||||
{
|
||||
yield 1;
|
||||
}
|
||||
}
|
||||
|
||||
/** @param \IteratorAggregate<mixed, int> $i */
|
||||
function takesIteratorOfInts(\IteratorAggregate $i) : void {
|
||||
foreach ($i as $j) {
|
||||
echo $j;
|
||||
}
|
||||
}
|
||||
|
||||
takesIteratorOfInts(new SomeIterator());',
|
||||
],
|
||||
'allowTemplatedIntersectionToExtend' => [
|
||||
'<?php
|
||||
interface Foo {}
|
||||
@ -1525,57 +1503,6 @@ class TemplateTest extends TestCase
|
||||
|
||||
echo Foo(DateTime::class)->format("c");',
|
||||
],
|
||||
'genericInterface' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template T as object
|
||||
* @param class-string<T> $t
|
||||
* @return T
|
||||
*/
|
||||
function generic(string $t) {
|
||||
return f($t)->get();
|
||||
}
|
||||
|
||||
/** @template T as object */
|
||||
interface I {
|
||||
/** @return T */
|
||||
public function get() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T as object
|
||||
* @template-implements I<T>
|
||||
*/
|
||||
class C implements I {
|
||||
/**
|
||||
* @var T
|
||||
*/
|
||||
public $t;
|
||||
|
||||
/**
|
||||
* @param T $t
|
||||
*/
|
||||
public function __construct(object $t) {
|
||||
$this->t = $t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return T
|
||||
*/
|
||||
public function get() {
|
||||
return $this->t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T as object
|
||||
* @param class-string<T> $t
|
||||
* @return I<T>
|
||||
*/
|
||||
function f(string $t) {
|
||||
return new C(new $t);
|
||||
}',
|
||||
],
|
||||
'templateIntersectionLeft' => [
|
||||
'<?php
|
||||
interface I1 {}
|
||||
|
Loading…
Reference in New Issue
Block a user