You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks like this is because of $knownAliases[$join['joinAlias']] = true. Although we specify the type of $knownAliases as array<string, true>, given that the type of $join['joinAlias'] is unknown to PHPStan, setting this key on the array makes it array<int|string, true>.
Unless there's a way to specify the type of joinAlias on $join (like array{joinAlias: string} in Psalm), we could use an assertion.
Bug report
This is similar to #1847, but we're still getting the error with phpstan
0.11.19
and0.12.5
.Even though the array key type is known, in some situations it is not used to infer the type of
array_keys()
.Code snippet that reproduces the problem
Here the type of
array_keys($knownAliases)
is inferred asarray<int, int|string>
instead ofarray<int, string>
.Sandbox: https://phpstan.org/r/98b7db20-f773-49d9-86d7-014f5d209483
Travis: https://travis-ci.org/doctrine/dbal/jobs/638201455
If you remove lines 45-48 (after the culprit), it suddenly works:
https://phpstan.org/r/586a6826-b4f7-4ea0-8c62-f3fa8a643a1a
Expected output
Actual output
The text was updated successfully, but these errors were encountered: