-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Summary of a problem or a feature request
When a null comparison is store on a variable, it not considered by PHPSTan.
Code snippet that reproduces the problem
$isLastInvoice = null !== $purchase->getCancellationDate() && $purchase->getCancellationDate()->getTimestamp() < $invoice->getPeriodEnd()->getTimestamp();
$proportionBeginDate = $purchase->getNextInvoiceDate();
$proportionEndDate = $isLastInvoice ? $purchase->getCancellationDate() : $invoice->getPeriodEnd();
$proportionDiffMonths = DateDiff::diffMonths($proportionBeginDate, $proportionEndDate);$purchase->getCancellationDate() is checked against null on $isLastInvoice.
Expected output
Nothing, it should be good AFAIK. But I have:
Parameter #2 $date2 of static method AppBundle\Tools\DateDiff::diffMonths() expects DateTime, DateTime|null given.
I don't have the issue without boo-lean variable storage:
$proportionBeginDate = $purchase->getNextInvoiceDate();
$proportionEndDate =
null !== $purchase->getCancellationDate()
&& $purchase->getCancellationDate()->getTimestamp() < $invoice->getPeriodEnd()->getTimestamp()
? $purchase->getCancellationDate() : $invoice->getPeriodEnd()
;
$proportionDiffMonths = DateDiff::diffMonths($proportionBeginDate, $proportionEndDate);Maybe already reported, but I can't find something similar on the issue list.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels