On Fri, Nov 10, 2023 at 1:33 PM Craig Francis <cr...@craigfrancis.co.uk> wrote:
> On 10 Nov 2023, at 10:54, Alex Wells <autau...@gmail.com> wrote: > > PHPStan does find them: > https://phpstan.org/r/38fc1545-2567-49b9-9937-f275dcfff6f5 > > > > It does not: > > https://phpstan.org/r/c533ff42-80e4-4309-9751-1ec79e359946 > > It fails to correctly change the type of the variable to nullable due to the coalescing operator. This is a bug in PHPStan, but if you manually specify the type of that variable as nullable, it starts to correctly report an error on line 5. So it's not that PHPStan can't find places where a null is passed into a non-nullable parameter, but rather PHPStan failing to infer the variable type correctly, thinking it's actually not nullable.