-
-
Notifications
You must be signed in to change notification settings - Fork 946
Description
Bug report
Hi, I'm not sure how to describe this error, but:
When implementing method with variadic templated type - that type becomes array<int, T>. For example: TKey becomes array<int, TKey>.
/**
* @template TKey
* @template TValue
*/
interface A
{
/**
* @phpstan-param array<int, TKey> $keys
* @phpstan-return A<TKey, TValue>
*/
public function methodName(...$keys): A;
}
/**
* @template TKey
* @template TValue
* @implements A<TKey, TValue>
*/
class AI implements A
{
/**
* @phpstan-param array<int, TKey> $keys
* @phpstan-return A<TKey, TValue>
*/
public function methodName(...$keys): A
{
// return type of parent method is detected as array<int, TKey>
}
}(full examples below)
Am I doing something wrong? :) Or this is a bug?
Code snippet that reproduces the problem
https://phpstan.org/r/1e9e5aab-3494-40bb-ab40-fe58993224af
https://phpstan.org/r/d78732e7-1bbb-41d4-bba6-e7dd6e6fd36c
The same error occurs with variadic syntax TKey ...$keys:
https://phpstan.org/r/25ea56c5-c03b-426d-b274-a0fda1df4b60
"Concrete variadic" types are ok:
https://phpstan.org/r/2ebfc221-b297-4c58-9843-e89f72666b98
Passing int as TKey by @implements does not produce error:
https://phpstan.org/r/6bb97423-efe2-4ed7-b78e-dd334d67e7d2
Expected output
No errors like in https://psalm.dev/r/e8a2f1414d or https://psalm.dev/r/d8ad951558