-
-
Notifications
You must be signed in to change notification settings - Fork 934
Description
Bug report
First of all, thanks for making my life so much easier with PHPStan! I love it ❤️
My problem is that PHPStan does not seem to correctly determine the return type of my variadic function. According to https://phpstan.org/writing-php-code/phpdocs-basics#variadic-functions, I annotated the parameter type as follows:
/**
* @param array<int, string> ...$templatePaths
* @return array<int, string>
*/
public static function merge(array ...$templatePaths): array
{
$mergedTemplatePaths = array_replace(...$templatePaths);
ksort($mergedTemplatePaths);
return $mergedTemplatePaths;
}But it keeps reporting:
Method TemplatePaths::merge() should return array<int, string> but returns array<int|string, array<int, string>>.
Code snippet that reproduces the problem
https://phpstan.org/r/30d06460-a26c-4383-b1b3-259d8ced39b2
Example: https://3v4l.org/0gZdk
Expected output
From my understanding, there shouldn't be an issue with my annotation as it can be seen in the example. But I must probably mixed something up with the variadics...
Did PHPStan help you today? Did it make you happy in any way?
PHPStan is part of my daily business and it's literally one of the first things I add to each new project 💙. Thanks for all your efforts and constant development!