Hi,
The following test does not allow to resolve the ->append(...) method for the 3 cases:
<?php
declare(strict_types=1);
namespace Devsense\Generics\Iterator\Test1;
use ArrayIterator;
use IteratorAggregate;
/**
* @template TValue
* @implements IteratorAggregate<TValue>
*/
abstract class AbstractList implements IteratorAggregate
{
/**
* @return ArrayIterator<TValue>
*/
public function getIterator(): ArrayIterator
{
return new ArrayIterator([1, 2, 3, 4]);
}
}
/**
* @template TValue
* @extends AbstractList<TValue>
*/
abstract class AbstractArray extends AbstractList {}
/**
* @extends AbstractArray<static>
*/
class MyArray extends AbstractArray
{
public function append(mixed $value) {}
}
/**
* @extends AbstractArray<self>
*/
class MyStore extends AbstractArray
{
public function append(mixed $value) {}
}
/**
* @extends AbstractArray<MyData>
*/
class MyData extends AbstractArray
{
public function append(mixed $value) {}
}
$array = new MyArray();
foreach($array as $list) {
$item->append('');
}
$store = new MyStore();
foreach($store as $list) {
$item->append('');
}
$data = new MyData();
foreach($data as $list) {
$item->append('');
}
Thank you for the fix.