Bug report
When the $date is null, whole remaining part of call chain should be resolved as null. When $date is not null, even the result of modify('+1 year') is resolved as not null and ?-> call for ?->setTime() is not necessary.
I also didn't find what is "officially correct way". But according to https://wiki.php.net/rfc/nullsafe_operator this should be equivalent to
if ($date !== null) {
$plus= $date->modify('+1 year');
return $plus->setTime(23, 59, 59);
}
return null;
Code snippet that reproduces the problem
https://phpstan.org/r/ba9428d7-9b8b-4029-9ba8-423be023a767
Expected output
No errors!
Did PHPStan help you today? Did it make you happy in any way?
No response
Bug report
When the $date is null, whole remaining part of call chain should be resolved as null. When $date is not null, even the result of modify('+1 year') is resolved as not null and ?-> call for ?->setTime() is not necessary.
I also didn't find what is "officially correct way". But according to https://wiki.php.net/rfc/nullsafe_operator this should be equivalent to
if ($date !== null) {
$plus= $date->modify('+1 year');
return $plus->setTime(23, 59, 59);
}
return null;
Code snippet that reproduces the problem
https://phpstan.org/r/ba9428d7-9b8b-4029-9ba8-423be023a767
Expected output
No errors!
Did PHPStan help you today? Did it make you happy in any way?
No response