snippet : https://psalm.dev/r/9ed57c8ff1
code :
<?php
/**
* @template Tk of array-key
* @template Tv
*/
interface ICollection {
/**
* @psalm-return ICollection<Tk, Tv>
*/
public function slice(int $start, int $length): ICollection;
}
/**
* @template T
*
* @extends ICollection<int, T>
*/
interface IVector extends ICollection {
/**
* @psalm-return IVector<T>
*/
public function slice(int $start, int $length): IVector;
}
expected output :
actual output :
Psalm output (using commit 55aceb2):
ERROR: LessSpecificImplementedReturnType - 21:20 - The inherited return type 'ICollection<int, T:IVector as mixed>' for ICollection::slice is more specific than the implemented return type for IVector::slice 'IVector<T:IVector as mixed>'
hack code :
namespace Psalm\LessSpecificImplmenetedReturnType;
interface ICollection<Tk as arraykey, Tv> {
public function slice(
int $start,
int $length
): ICollection<Tk, Tv>;
}
interface IVector<T> extends ICollection<int, T> {
public function slice(
int $start,
int $length
): IVector<T>;
}
hack type checker output :
snippet : https://psalm.dev/r/9ed57c8ff1
code :
expected output :
actual output :
hack code :
hack type checker output :