BinaryDriver icon indicating copy to clipboard operation
BinaryDriver copied to clipboard

Clarify if-statements when variable is declared

Open YogiLai opened this issue 5 years ago • 2 comments

代码bug? bug

YogiLai avatar Feb 18 '20 02:02 YogiLai

Thanks for filing the issue and reading/checking the code for errors! :)

No, in fact the = operator has a higher binding than the strictly-not comparison to null.

PS C:\Users\Jens> psysh
Psy Shell v0.9.12 (PHP 7.4.2 — cli) by Justin Hileman
>>> null !== $binary = true
=> true
>>> if (null !== $binary = true) { echo "Win!"; }
Win!⏎
>>> if (null !== ($binary = true)) { echo "Win!"; }
Win!⏎

Yet I'd agree this would increase readability. If you want to file a merge request, you're free to do so! :)

jens1o avatar Feb 18 '20 15:02 jens1o

Thank you for your answer

YogiLai avatar May 06 '20 00:05 YogiLai