Repository navigation
Conversation
|
Thank you for your PR. Could you also check the following case? function d5(?int $x) {
$x--;
return $x;
}
var_dump(d5(null));Currently, this produces the following warning: Should this case also be handled? |
|
I left that case alone because it is the intended behavior. |
|
Thanks for the clarification. This PR only addresses the incorrect optimization that changes the result. I think a separate PR would be needed to address the behavior of |
ndossche
left a comment
There was a problem hiding this comment.
This is fine, but add a comment to the edited lines that the MAY_BE_UNDEF|MAY_BE_NULL exists because of the currently inconsistent behaviour and that in PHP9 we should revisit this once the behaviour is fixed
|
Added the comment on both edited lines. |
The DFA pass turns
$x = $x - 1intoPRE_DECwhen the operand can only be null, undef or a number. That is fine for+ 1, but not for- 1:null - 1is-1, while--$xon null leaves it null. TheASSIGN_OPSUB rule right below already excludesMAY_BE_UNDEF|MAY_BE_NULL, so the twoSUBcontraction rules now do the same.Fixes GH-25061