Bug report
<?php declare(strict_types = 1);
class Token {}
/** @extends SplFixedArray<Token> */
class Tokens extends SplFixedArray {}
/** @param array<int, Token>|Tokens $tokens */
function x(iterable $tokens): int {
return count($tokens);
}
PHPStan resolves the type of $tokens inside x to iterable<int, Token>|Tokens. But it should be array<int, Token>|Tokens, as noted in phpdocs.
I cannot use native array|Tokens union type for bc reasons and for compatibility to php 7.4 (real code is here).
Code snippet that reproduces the problem
https://phpstan.org/r/dc5f61e0-0c94-4e1b-a61b-971794274b95
Expected output
No errors.
Did PHPStan help you today? Did it make you happy in any way?
No response