-
-
Notifications
You must be signed in to change notification settings - Fork 935
Closed
Labels
Milestone
Description
Bug report
Having a code:
<?php declare(strict_types = 1);
/**
* @param array{0: string, 1?: string} $a
* @return array{0: string, 1?: string}
*/
function rrr(array $a): array
{
return array_reverse($a);
}
it results with an error:
Function rrr() should return array{0: string, 1?: string} but returns array{0?: string, 1: string}.
which is not true, having array of 1 or 2 strings revered, it will always results with an array of 1 or 2 strings.
Code snippet that reproduces the problem
https://phpstan.org/r/13270977-2e74-413f-9d7f-904dd76b9096
Expected output
No issue reported.
Did PHPStan help you today? Did it make you happy in any way?
No response