See https://phpstan.org/r/c93e00ea-82a6-484a-b1e6-ac2a4f443693
The in_array() warning is wrong there at the end, as 10 may or may not be inside array{0: 10|20, 1?: 20} (which could be array{0: 20} for example.
In case it's more readable or to understand what the code does it comes from https://github.com/composer/composer/blob/6be6ce7d9f911c248139976703b73f4876c8a38f/src/Composer/Downloader/PathDownloader.php#L254-L279 originally.