Bug report
PHPStan do not understand GOTO and LABEL, if you put them into code, PHPStan just ignore them instead of treating them as loop.
<?php declare(strict_types = 1);
/** @return int[]|null */
function getData(): ?array {
return rand(0,1) ? [1,3,5] : null;
}
TEST:
$data = getData();
if (!$data) {
goto TEST;
}
foreach ($data as $item) {
echo $item;
}
Code snippet that reproduces the problem
https://phpstan.org/r/8c8e0d6d-60ef-4f7a-8dd1-8cb3c2916428
Expected output
No error should be found, as variable can contain only array at this point
Did PHPStan help you today? Did it make you happy in any way?
Yeah, every day
Bug report
PHPStan do not understand GOTO and LABEL, if you put them into code, PHPStan just ignore them instead of treating them as loop.
Code snippet that reproduces the problem
https://phpstan.org/r/8c8e0d6d-60ef-4f7a-8dd1-8cb3c2916428
Expected output
No error should be found, as variable can contain only array at this point
Did PHPStan help you today? Did it make you happy in any way?
Yeah, every day