-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-src
#6668Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/fec3769b-6fbc-4e6e-a8ea-958bdea5ea9a
<?php
function getExpiredAt(): \Datetime|null
{
return null;
}
if ($expired = getExpiredAt()) {
echo $expired->format('Ymd');
}Responsible rules
ExplicitBoolCompareRector
Expected Behavior
The rector converts $expired = getExpiredAt() into $expired = getExpiredAt() !== null.
The issue is, that the precedence is not the same: $expired = getExpiredAt() !== null is evaluated as $expired = (getExpiredAt() !== null) instead of (expected) ($expired = getExpiredAt()) !== null
see https://3v4l.org/ugYkh for precedence